Friday, 15 February 2013

wysihtml5 - Why can't I select something like iframe > html > body via jQuery? -



wysihtml5 - Why can't I select something like iframe > html > body via jQuery? -

i'm using wysihtml5 plugin, add together rich editor textarea.

so, plugin turns this:

<textarea></textarea>

into this:

<textarea style="display:none;"></textarea> <iframe> <header> <header> <body class="wysihtml5-editor"> </body> </iframe>

i found info here, add together character counter:

wysihtml5textarea.data("wysihtml5").editor.observe("load", function() { wysihtml5textarea.data("wysihtml5").editor.composer.element.addeventlistener("keyup", function() { var wysihtml5_cur_length = 0; wysihtml5_cur_length = $('.wysihtml5-editor').val().length; alert(wysihtml5_cur_length); }); });

according author of plugin:

solution not hear on textarea keyup events instead on 's body

so that's did, listened iframe > html > body: .wysihtml5-editor

but right now, next error:

uncaught typeerror: cannot read property 'length' of undefined

so means jquery part not locating body reason (it locate elements not within iframe).

what problem , possible solutions?

you can @ iframe content via contentwindow

something works me:

var editor_body = $(".wysihtml5-sandbox").contentwindow.document.body; $(editor_body).keyup(function() { console.log($(this).text()); });

jquery wysihtml5

No comments:

Post a Comment