Thursday, 15 April 2010

javascript - Nicedit.js - cannot add custom button -



javascript - Nicedit.js - cannot add custom button -

i adopted code snippet here - changed custom button icon path, but button doesn't appear. there no errors in console.

/** * nicexample * @description: illustration button plugin nicedit * @requires: niccore, nicpane, nicadvancedbutton * @author: brian kirchoff * @version: 0.9.0 */ /* start config */ jquery("document").ready(function(){ debugger; var nicexampleoptions = { buttons : { 'example' : {name : __('some alt text button'), type : 'niceditorexamplebutton'} }, iconfiles : {'example' : '/assets/emoticons/aa.gif'} }; var niceditorexamplebutton = niceditorbutton.extend({ mouseclick : function() { alert('the illustration save button icon has been clicked!'); } }); niceditors.registerplugin(nicplugin,nicexampleoptions); });

also add together custom button name editor button list:

this.instantiate_nicedit_for_textarea = function(textarea){ var nic_editor = new niceditor({buttonlist : ['bold','italic','underline','strikethrough','example'], iconspath : '/assets/niceditoricons.gif'}) nic_editor.addinstance(textarea.id); var topbar_id = $(textarea).prevall('div.widget_topbar').last().children('ul').children('li.nic_panel').attr('id'); nic_editor.setpanel(topbar_id); };

update: firefox 18.02, chrome 22.0.1229.94

based on save button plugin, how code should look:

var nicexampleoptions = { buttons : { 'example' : {name : __('example'), type : 'niceditorexamplebutton'} } }; var niceditorexamplebutton = niceditorbutton.extend({ init : function() { // init code }, mouseclick : function() { alert('hallo!'); // code here } }); niceditors.registerplugin(nicplugin,nicexampleoptions);

as best practice, sugest add together code in separated file, , create sure loaded after nicedit.js. then, can add together button instance's buttonlist.

javascript nicedit

No comments:

Post a Comment