按需加载CKeditor和Jquery

发布于 2024-09-27 22:18:22 字数 223 浏览 0 评论 0原文

我目前在我的网站上使用 CKEditor,但并非每次用户访问页面时都需要 CKEditor。流程如下:用户进入页面并看到该页面的所有文章;如果用户想要编辑文章,他或她会打开编辑器并执行此操作。目前,CKEditor 被加载到隐藏的 div 中,并且有 60% 的时间没有被使用。当用户单击并让编辑器 div 可见时,有什么方法可以按需加载它?

我的 CKEditor 使用 Jquery 连接器

谢谢

I currently use CKEditor on my website, however not every time users access the page CKEditor is needed. The flow is the following: user enters the page and see all the articles there; if users wants to edit the article he ou she opens editor and does that. Cureently CKEditor is loaded in the hidden div and not used 60% of time. Is there any way to load it on demand when user clicks and get that editor div visible?

My CKEditor uses Jquery connector

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌辣 2024-10-04 22:18:22

这取决于你想如何做到这一点,但如果没有看到你的标记,我建议尝试类似的操作:

$('a.editThis').click( // assuming that someone clicks a link of class-name 'editThis' to edit the page
  function(){
    $('<script src="/path/to/CKEditor.js"></script>').appendTo('head');
    return false;
  }
);

编辑以添加演示的链接,尽管这是附加 CSS 的演示。我想可以添加 javascript,接下来我会尝试一下。演示地址:我的网站

It depends on how you want to do it, but without seeing your mark-up I'd suggest trying something like:

$('a.editThis').click( // assuming that someone clicks a link of class-name 'editThis' to edit the page
  function(){
    $('<script src="/path/to/CKEditor.js"></script>').appendTo('head');
    return false;
  }
);

Edited to add a link to a demo, albeit this is a demo of appending CSS. I'd imagine that javascript can be added though, and I'll try that next. Demo at: my site

君勿笑 2024-10-04 22:18:22

对于其他不使用 JQuery 的人,他们应该知道 CKEditor 确实包含自己的惰性加载器:http://alfonsoml.blogspot.com/2009/09/delayed-loading-of-ckeditor.html

For other people that don't use JQuery, they should be aware that CKEditor does include its own lazy loader: http://alfonsoml.blogspot.com/2009/09/delayed-loading-of-ckeditor.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文