~ overflow ~

Tag: jwysiwyg

Reset jwysiwyg

by z3n on Jan.15, 2010, under Coding, Games and Gaming

Problem:

jquery’s extension jwysiwyg can’t be reseted on fly, calling the function again will just append another editor.

Solution:

You will need to do a workaround by adding the jwysiwyg object inside a container then resetting it using this little function:

  1. function _reset_jwysiwyg(h,x,j){ // html, first id, second id
  2.    h=str_replace("\\","",h); // this requires php.js to work, can be removed if you don't add slashes on your vars
  3.    $("#cf"+x+""+j).html("<textarea id='#f"+x+""+j+"' class='jwysiwyg' name='jwysiwyg' cols=94 rows=30>"+h+"</textarea>");
  4.    $(".jwysiwyg").wysiwyg({
  5.        html: h
  6.       // you may want to add other control options here
  7.   });
  8. }

this will work for this setup:
<span id=’c12′><textarea id=’f12′ class=’jwysiwyg’ name=’jwysiwyg’ cols=94 rows=30></textarea></span>

on this example it will be called as:

_reset_jwysiwyg(“”,1,2);

Note

this function is a snippet from my code, you might not want the identifiers just the div name, that makes it less complicated.

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!