[Proto-Scripty] Re: onChange event when div content changed
On Sep 3, 12:07 am, Hipnotik pork...@gmail.com wrote: Hi How to call some action if content of the div element has changed? I'm talking about something like this: $(my-div).observe(change, function(e) { alert(hello); }); Expecting behavior: I have this div id=my-divsome text/div now I'm changing some text to some other text and alert(hello) should be fired. There is no change event specified for div elements, what you are looking for is provided by DOM mutation events: URL: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MutationEvent OK in Firefox, Opera, Safari and a few others, but not IE. Some help here: URL: http://www.howtocreate.co.uk/tutorials/javascript/domevents The best cross-browser strategy is to get the function that modifies the DOM to call the function you'd like to add as a DOMSubtreeModified listener. -- Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onChange event when div content changed
You could use prototype custom events. See example here: http://jsbin.com/ayiku But you will have to fire function manually after update or override default Element.update function to do it for you. Marko On Sep 2, 7:30 pm, Hipnotik pork...@gmail.com wrote: Thanks Walter! I would like to avoid of using PE and global variable to store current innerHTML. I thought that it will be quiet easy and any trick can help me... There is other way - hidden form field and prototype's observer. But this solution doesn't satisfy me too. Anyway, thanks. On 2 Wrz, 17:30, Walter Lee Davis wa...@wdstudio.com wrote: There's no reliable cross-browser event that gets fired when the content of a DIV (as opposed to a form element, say) changes. One thing you might try would be to have a PeriodicalExecuter running. Have it compare a global variable with the current innerHTML of that DIV, and if they don't match, fire the event and update the global variable. This may be more difficult than I am saying it here, it's often quite hard to get a PE to gather an external variable value more than once (at the moment the PE function is instantiated). Walter On Sep 2, 2009, at 10:07 AM, Hipnotik wrote: Hi How to call some action if content of the div element has changed? I'm talking about something like this: $(my-div).observe(change, function(e) { alert(hello); }); Expecting behavior: I have this div id=my-divsome text/div now I'm changing some text to some other text and alert(hello) should be fired. Thnaks for help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onChange event when div content changed
@RobG I'm not sure that DOMSubtreeModified works in the IE. I tried to use it and I think it doesn't. @Marko That's the problem... I don't want to fire it manually. But thanks guys for help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onChange event when div content changed
Thanks Walter! I would like to avoid of using PE and global variable to store current innerHTML. I thought that it will be quiet easy and any trick can help me... There is other way - hidden form field and prototype's observer. But this solution doesn't satisfy me too. Anyway, thanks. On 2 Wrz, 17:30, Walter Lee Davis wa...@wdstudio.com wrote: There's no reliable cross-browser event that gets fired when the content of a DIV (as opposed to a form element, say) changes. One thing you might try would be to have a PeriodicalExecuter running. Have it compare a global variable with the current innerHTML of that DIV, and if they don't match, fire the event and update the global variable. This may be more difficult than I am saying it here, it's often quite hard to get a PE to gather an external variable value more than once (at the moment the PE function is instantiated). Walter On Sep 2, 2009, at 10:07 AM, Hipnotik wrote: Hi How to call some action if content of the div element has changed? I'm talking about something like this: $(my-div).observe(change, function(e) { alert(hello); }); Expecting behavior: I have this div id=my-divsome text/div now I'm changing some text to some other text and alert(hello) should be fired. Thnaks for help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---