Search code examples
jqueryeventstextcallback

Searching for a way to call a function after ".text()" on jQuery


Is there any way to have a function triggered after the $('myitem').text() is completed when using jQuery? I can't use a callback function because jQuery does not support it for .text().


Solution

  • Might be off base here but the reason your changes are not correctly styled is because the plugin is trying to be efficient. It doesn't seem to be designed for continual updating. To force it to work you need to get the plugin to reinitialise each time. I have removed the class attribute to do that (example).

    Another way to do it which won't be as intensive is to use a timeout (as Marnix) suggested. Here is an example of this.

    Finally you could use a different event altogether like blur() (so the formatting is only applied after the area loses focus) or create a 'format' button and assign a click event.

    I know it is not strictly what you are asking for, but I hope this helps!

    Note: All examples only tested in Chrome.