Note that there are some explanatory texts on larger screens.

plurals
  1. POckeditor 4 accessing focusmanager with dynamically created editor insantces
    primarykey
    data
    text
    <p>i currently have 1 editor that will always be on the page when it loads, the page has a feature to add multiple editors by clicking a add button.</p> <p>my code works on the first editor only that is loaded with the page, how can i adapt this to work on all the editors on the page, even if dynamically created after the page has been loaded? (the dynamically created editors)</p> <pre><code>$(document).ready(function(){ $.each(CKEDITOR.instances, function(instance){ var editor = CKEDITOR.instances[instance]; if (editor) { editor.on( 'focus', function( e ) { $('.hint').show(); }); editor.on( 'blur', function( e ) { $('.hint').hide(); }); } }); }); </code></pre> <p><strong>eidt 1</strong> - fullcode minus html</p> <pre><code>$(document).ready(function(){ $('textarea').each(function(i) { var editorId = $(this).attr('id'); if(editorId != 'master'){ if( $(this).hasClass('main') ){ ckeditor_simple_toolbar(editorId); } if( $(this).hasClass('extras') ){ ckeditor_advanced_toolbar(editorId); } } }); $.each(CKEDITOR.instances, function(instance){ var editor = CKEDITOR.instances[instance]; if (editor) { editor.on( 'focus', function( e ) { $('.hint').show(); }); editor.on( 'blur', function( e ) { $('.hint').hide(); }); } }); $('.add_extra').live('click',function(){ ckeditor_advanced_toolbar(this.id); }); }); function ckeditor_simple_toolbar(textA_id){ CKEDITOR.replace(textA_id,{ tabSpaces : 4 }); } function ckeditor_advanced_toolbar(textA_id){ CKEDITOR.replace(textA_id,{ emailProtection : 'encode', tabSpaces : 4, extraPlugins : 'autogrow', height : 100, autoGrow_minHeight : 100, autoGrow_maxHeight : 400, removePlugins : 'resize', toolbarLocation : 'bottom', }); } </code></pre> <p><strong>edit 2</strong> here is a test setup of what is happening, the focus and blur aren't working on the dynamically added editors</p> <p><a href="http://elhalawa.net/editor/index.html" rel="nofollow">http://elhalawa.net/editor/index.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload