Reputation: 22710
I am using jquery's change()
method in my code.
$("select,input,textarea").change(function ()
{
needToConfirm = true;
alert("needToConfirm :" + needToConfirm);
})
It's working fine with all select
, input
as well as textarea
element except for following textarea
element
<textarea name="myTextArea" id="myTextArea" class="mceEditor" rows="4" cols="125">${myForm.someAttribute }</textarea>
I observed that other textarea
don't have any dynamic value while this myTextArea
have ${myForm.someAttribute}
value. This seems to be the cause but I am not able to figure out the exact reason.
Its working fine with following textarea
element
<textarea path="studySummary" cssClass="fieldValue mediumFontSize" rows="4" cols="95" tabindex="67"/>
EDIT:
Hello All,
All things are working fine but I came across a new issue. I have some HTML elements like select
,input
etc which get added dynamically through javascript. How can I bind jquery's change()
method to this dynamically added elements ? Right now change()
is only invoked for static elements.
EDIT2
Got the solution. Copy of this question.
Upvotes: 2
Views: 186
Reputation: 196026
I am assuming from the class="mceEditor"
that you are using the tinyMCE editor.
This will replace the actual element, and so your code will not run on the new element.
Here is the proposed way on handling such a case http://tinymce.moxiecode.com/wiki.php/Configuration:onchange_callback
You basically have to put your change code in a function, and use that when initializing the tinyMCE.
function handleChange() {
needToConfirm = true;
alert("needToConfirm :" + needToConfirm);
}
$("select,input,textarea").change(handleChange);
and also when you call the tinyMCE initialization add the
tinyMCE.init({
...
onchange_callback : handleChange //<-- ADD THIS PART
});
Upvotes: 1
Reputation: 13115
MCS editor internally using your textarea with class="mceEditor"
...because of this when you change content of textarea it first call the mceEditor onChange event
Upvotes: 0