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

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

问题描述

我已经通过使用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.

当点击链接时,此代码会按预期输出string和锚标记的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方法。似乎(遗憾的是)解决方案是不使用jitery版本的tinymce。

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()返回一个Object的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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