fancybox 2和tinymce jquery冲突 [英] fancybox 2 and tinymce jquery conflict

查看:76
本文介绍了fancybox 2和tinymce jquery冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站的许多区域使用fancybox-2.0.1并且一直这样做没有问题。我也一直使用tinquce的jquery实现和fancybox没有问题。但是,由于我将tinymce inti脚本更改为如下所示我开始遇到问题:

I am using fancybox-2.0.1 in a number of areas on a website and have been doing so without a problem. I have also been using the jquery implementation of tinymce in conjunction with fancybox without a problem. However, since I changed the tinymce inti script to look like the below I started getting problems:

<script type="text/javascript" src="tinymceJQ/jscripts/tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">
$(function() {

var $editor = $("#appContentTextArea");

// Initialize WYSIWYG
$editor.tinymce({
    script_url : 'tinymceJQ/jscripts/tiny_mce/tiny_mce.js',
    theme : "advanced",
    mode : modeAlter,
    /*editor_selector : "mceEditor",*/
    content_css : "css/webPage.css",
    paste_text_sticky: true,
    paste_text_sticky_default: true,
    relative_urls: false,
    remove_script_host : false,
    remember_last_path : false,
    imagemanager_rootpath: accountFolder,
    theme_advanced_buttons1 : "bold, italic, underline, strikethrough, separator, justifyleft, justifycenter, justifyright, justifyfull, separator, formatselect, forecolor, separator, hr, removeformat, separator, cut, copy, image, separator, aquaHeading, sponsorDiv",
    theme_advanced_buttons2: "code, separator, link, unlinkbullist,numlist,tablecontrols, fontselect",
    theme_advanced_buttons3: "",
    setup : function(ed) {
        ed.onInit.add(function() {
            // do something
        });
    },
    oninit : tinyMceReady
});
</script>

一旦我更改为此初始化,Fancybox将不再打开URL。相反,它会启动正确大小的弹出窗口,但内容将是无法加载请求的内容。请稍后再试。

As soon as I changed to this init Fancybox would no longer open the URL. Instead it would launch the correctly sized pop-up but the contents would be "The requested content cannot be loaded. Please try again later."

是否有人知道冲突使用新的fancybox和tinymce,或者可以看到上述代码中的冲突?

Is anyone aware of a conflict with the new fancybox and tinymce, or can see a conflict in the above code?

提前感谢任何可以提供帮助的人。

Thanks in advance to anyone who can help.

推荐答案

许多JavaScript库使用$作为函数或变量名,就像jQuery一样。在jQuery的情况下,$只是jQuery的别名,因此所有功能都可以在不使用$的情况下使用。如果我们需要在jQuery旁边使用另一个JavaScript库,我们可以通过调用$ .noConflict()将$的控制权返回给另一个库:

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():

<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $.noConflict();
  // Code that uses other library's $ can follow here.
</script>

这种技术与.ready()方法对jQuery对象进行别名的能力特别有效,如果在回调中传递给.ready(),我们可以使用$,如果我们愿意,而不用担心以后的冲突:

This technique is especially effective in conjunction with the .ready() method's ability to alias the jQuery object, as within callback passed to .ready() we can use $ if we wish without fear of conflicts later:

<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $.noConflict();
  jQuery(document).ready(function($) {
    // Code that uses jQuery's $ can follow here.
  });
  // Code that uses other library's $ can follow here.
</script>

如果有必要,我们可以通过将true作为参数传递给方法来释放jQuery名称。这很少是必要的,如果我们必须这样做(例如,如果我们需要在同一页面上使用多个版本的jQuery库),我们需要考虑大多数插件都依赖于jQuery变量的存在和在这种情况下可能无法正常运作。

If necessary, we can free up the jQuery name as well by passing true as an argument to the method. This is rarely necessary, and if we must do this (for example, if we need to use multiple versions of the jQuery library on the same page), we need to consider that most plug-ins rely on the presence of the jQuery variable and may not operate correctly in this situation.

参考网址

这篇关于fancybox 2和tinymce jquery冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆