我创建了这样的自定义按钮
setup: function (ed) {
ed.addButton('fancybox_button', {
title: 'Fancybox button',
image: 'img/button.gif',
onclick: function() {
fancybox_button();
}
});
}
这有效并且该按钮出现在工具栏中。接下来,我在tinyMCE.init之前有像这样的fancybox_button函数
function fancybox_button() {
$.fancybox({
padding : 0,
minHeight : 560,
minWidth : 950,
...
});
}
通过单击自定义按钮,我会收到此错误
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'fancybox'
我该如何正确地做到这一点?
最佳答案
我假设 jquery 位于您的页面上,因为错误谈到了它,所以看起来 fancybox js 脚本丢失了,或者您的 fancybox js 脚本声明位于页面中 jquery 脚本的上方。
关于jquery - 如何使用自定义按钮在tinyMCE中打开fancybox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12971148/