简体   繁体   中英

Script for redactor.js doesn't work

I try to create a simple test-Script in Jsfiddle for a external Script (redactor.js), but it doesn't work :-(

if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {};

RedactorPlugins.advanced = {
    init: function () {
        alert(1);
    }
}

$('#article').redactor({
    plugins: ['advanced']
});

JSFiddle: http://jsfiddle.net/DEYx7/ I don't get the alert...

But I don't know, what I'm doing wrong, cause that is a quite simple example and it should work...

The Example-Code of the external redactor.js-Script: http://imperavi.com/redactor/docs/plugins-creating/

You need to define your plugin first , and make the plugin object globally available. Please see the updated JSFiddle :

if (typeof RedactorPlugins === 'undefined') window.RedactorPlugins = {};

RedactorPlugins.advanced = {
    init: function () {
        alert(1);
    }
}
$.getScript("http://imperavi.com/js/redactor/redactor.js",function(){
    $('#article').redactor({
        plugins: ['advanced']
    });   
});

I removed the redactor.js script from the automatically loaded scripts, in order to execute your plugin definition first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM