TinyMCE 和 jQuery - attr() 正在返回一个对象 [英] TinyMCE and jQuery - attr() is returning an Object

查看:25
本文介绍了TinyMCE 和 jQuery - attr() 正在返回一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过使用 data() 而不是 attr() 解决了这个问题,但我仍然想知道这是否只是我,以及是什么原因造成的:

I've solved this by using data() instead of attr(), but I'd still like to know if this is just me, and what's causing it:

我使用的是 jQuery 1.7.1 和 TinyMCE 3.5b3(jQuery 包).没有其他 JS 库.

I'm using jQuery 1.7.1 and TinyMCE 3.5b3 (jQuery package). No other JS libraries.

此代码在点击链接时输出字符串"和锚标记的 href,正如预期的那样.

This code outputs "string", and the anchor tag's href, as expected, when the link is clicked.

$('a.page_item_delete').on('click', function(event){
    event.preventDefault();
    var $this = $(this);
    console.log(typeof $this.attr('href'));
    console.log($this.attr('href'));
});

当我在页面上的某些 textareas 上激活 TinyMCE 时,它输出Object",当然,attr() 停止返回预期值.我正在通过以下方式激活 TinyMCE:

When I activate TinyMCE on some textareas on the page, it outputs "Object" and, of course, attr() stops returning an expected value. I'm activating TinyMCE via:

$('textarea.tinymce').tinymce(options);

$('textarea.tinymce').tinymce(options);

有没有其他人在 TinyMCE 上遇到过这种行为?是否存在已知错误或解决方法?为什么 TinyMCE 明显影响页面上不相关的 HTML 元素?

Has anyone else experienced this behaviour with TinyMCE? Is there a known bug, or workaround? Why is TinyMCE apparently affecting unrelated HTML elements on the page?

推荐答案

我遇到了同样的问题.它是由 tinymce-jquery 包覆盖 jquery 对象的 attr 和 css 方法引起的.似乎(可悲的是)解决方案是不使用 tinymce 的 jquery 版本.

I am having the same problem. It is being caused by the tinymce-jquery package overriding the attr and css methods of the jquery object. It seems (sadly) that the solution is to not use the jquery version of tinymce.

我还没有弄清楚为什么这不是 jquery 1.6 的问题,而是 1.7 的问题.

I haven't worked yet out why this wasn't a problem with jquery 1.6 and is a problem with 1.7.

我像这样使用 jquery 插件:

I was using the jquery plugin like this:

$('.wysiwyg', '#EditForm').tinymce({
    -- SETTING HERE
});

现在我已经完成了以下操作来复制我在使用 jquery 插件时所需的行为:

and now I have done the following to replicate the behavior I required when using the jquery plugin:

$('.wysiwyg', '#EditForm').each(function(){
    id = $(this).attr('id');
    var ed = new tinyMCE.Editor(id, {
    -- SETTINS HERE --          
    });
    ed.render();
});

希望能帮到你

这篇关于TinyMCE 和 jQuery - attr() 正在返回一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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