jQuery UI可在CKEditor中resize
我试图在使用jQuery UI Resizable的CKEditor实例中获取。
我使用以下代码来设置jQuery UI Resizable:
var ckinstance = CKEDITOR.instances.ckeditor-1; ckinstance.on("instanceReady", function() { $(ckinstance.document.$).find(".gallery").resizable(); });
这似乎只有一半的工作。 如果我在CKEditor实例中检查HTML,则div具有句柄等的所有jQuery UI Resizable标记,但div似乎无法resize。
有谁知道为什么div不会resize?
我不明白为什么jQuery UI Resizable。 CKEditor已经拥有自己的大小调整API:
- editor.resize()用于按需resize
- config.resize_enabled , config.resize_maxHeight , config.resize_maxWidth等 – 控制resize过程
也许你应该更好地重新思考你的目标。 无论如何,如果你真的想使用jQuery UI,请考虑这个HTML:
以下JavaScript:
(function( $ ) { var editor = CKEDITOR.replace( 'editor1', { width: '100%', resize_enabled: false // Disable native CKEditor resize. }); $( "#resizable" ).resizable({ resize: function( event, ui ) { editor.resize( '100%', ui.size.height - 2 ); // Play with this. } }); })( jQuery );
编辑器将自动调整到您的#resizable
容器。 如果性能至关重要(旧浏览器),请考虑使用stop事件 。
玩得开心!