Hi,
I am using FCKeditor - http://www.fckeditor.net - to allow textual input in a web page. The user can type whatever they want and then click the save button in the FCKeditor instance when they are finished. When the save button is clicked a Javascript function that I have written is executed to retrieve the user input and update the HTML form. My function is linked to the save button in the FCKeditor instance using the following line of code - -
function FCKeditor_OnComplete( editorInstance )
-
{
-
editorInstance.LinkedField.form.onsubmit = doSave;
-
}
-
This however causes the doSave function to be called when the form is submitted.
Is there anyway of undefining the doSave function?
Thanks,
Sean
4 6639
Heya, Sean.
In fact there is!
Since EVERYTHING in JavaScript ( including functions) is an object, you can undefine or even redefine functions just like you would any other variable.
For example, you can: -
delete doSave;
-
-
doSave = 5;
-
-
doSave = function() { alert('hi!'); };
-
and so on.
Unfortunately no dice.
My code is as follows: -
function doSave()
-
{
-
alert( "Do Save" );
-
var editor = FCKeditorAPI.GetInstance( "myFCKeditor" );
-
var contentDiv = document.getElementById( contentSectionInEdit );
-
contentDiv.innerHTML = editor.GetHTML();
-
contentDiv.style.display = "none";
-
var shortDiv = document.getElementById( shortSectionInEdit );
-
-
var idxStart = contentDiv.innerHTML.indexOf( '<H' );
-
var idxEnd;
-
-
if( idxStart != -1 )
-
{
-
idxEnd = contentDiv.innerHTML.indexOf( '</H', idxStart );
-
idxEnd = contentDiv.innerHTML.indexOf( '>', idxEnd );
-
idxEnd++;
-
-
shortDiv.innerHTML = contentDiv.innerHTML.substring( idxStart, idxEnd );
-
}
-
else
-
{
-
idxStart = contentDiv.innerHTML.indexOf( '<h' );
-
-
if( idxStart != -1 )
-
{
-
idxEnd = contentDiv.innerHTML.indexOf( '</h', idxStart );
-
idxEnd = contentDiv.innerHTML.indexOf( '>', idxEnd );
-
idxEnd++;
-
-
shortDiv.innerHTML =
-
contentDiv.innerHTML.substring( idxStart, idxEnd );
-
}
-
else
-
shortDiv.innerHTML = contentDiv.innerHTML;
-
}
-
-
shortDiv.style.display = "";
-
-
return false;
-
}
-
-
function saveFormContents()
-
{
-
alert( "Save Form Contents" );
-
-
delete doSave;
-
-
var divToAppendTo = document.getElementById( "divToAppendToOnSubmit" );
-
-
var hiddenInputId = "divContents[]";
-
var existingInputs = document.getElementById( hiddenInputId );
-
-
if( existingInputs != null )
-
divToAppendTo.innerHTML = null;
-
-
var list = document.getElementById( 'sections' );
-
var items = list.getElementsByTagName("li");
-
-
for( var i = 0, n = items.length; i < n; i++ )
-
{
-
var hiddenField = document.createElement( "input" );
-
hiddenField.type = "hidden";
-
hiddenField.name = hiddenInputId;
-
hiddenField.id = hiddenInputId;
-
hiddenField.value = items[i].firstChild.nextSibling.innerHTML;
-
divToAppendTo.appendChild( hiddenField );
-
}
-
}
-
-
function FCKeditor_OnComplete( editorInstance )
-
{
-
editorInstance.LinkedField.form.onsubmit = doSave;
-
}
-
-
<input type="button" value="Add New Section" onclick="javascript:addSection();" /> <input type="submit" value="Save Changes" id="button_name" name="button_name" onclick="javascript:saveFormContents()" />
-
When I submit the form both saveFormContents and doSave are called. The alerts are printed, even though I have tried to delete the doSave function. I only want the doSave function to be called when the save button in FCKeditor is clicked, not when the form is submitted.
Hope you can help.
Sean
Heya, Sean.
In fact there is!
Since EVERYTHING in JavaScript (including functions) is an object, you can undefine or even redefine functions just like you would any other variable.
For example, you can: -
delete doSave;
-
-
doSave = 5;
-
-
doSave = function() { alert('hi!'); };
-
and so on.
Heya, Sean.
Seems like you'll want to figure out where FCKeditor_OnComplete() gets called. And then move or remove it.
I have found a way to basically determine if the form submit came from the FCKEditor or not. - function doSave(e) {
-
-
//e is null when its the FCKEditor save button
-
if (e == null) {
-
-
//Do your submit on FCKEditor save button work
-
-
return false; //this disables default action (submitting the form)
-
}
-
-
//if e isn't null its a valid asp.net form button that has been pressed and we do not need to return true to allow the form to continue submitting.
-
}
-
-
function FCKeditor_OnComplete(editorInstance) {
-
editorInstance.LinkedField.form.onsubmit = doSave;
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sam |
last post by:
HI,
I installed php4 for apached and restart apache afterward. but my little
php script generated error followint error:
PHP Notice: Undefined index: myname in...
|
by: Rafal 'Raf256' Maj |
last post by:
Hi,
is there a commend to undefine all macros #define inside a file?
in example:
#define FOR(x) for (..............)
#define MyMacro1(x,y) ...........
// ... code ...
|
by: Rich |
last post by:
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS
2005 (.NET v2.0.50727). The entire solution uses serveral technologies -
Windows Server 2003 (AD, SQL Server 2000, IIS,...
|
by: Alden Pierre |
last post by:
Hello,
I'm trying to create my own user define container, but I'm having a
little hard time figuring out why is my class considered undefined by my
compiler. Here is the following code.
//...
|
by: Rocky86 |
last post by:
hi people basically I am having a problem with the followinng code:
$names=sizeof($temp);
$report="total=$names&";
foreach($temp as $list)
$report.="name".$names--."=".$list."&";
echo...
|
by: Pietro Cerutti |
last post by:
Hi Group,
is there a mean to undefine a function, in a similar way as you can
undefine macros?
For example, let's say that I need a few declarations from stdio.h but
want to define my own...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |