[jQuery] Click-Event in Options/defaults
Hy
My jQuery-Plugin shoud produce two buttons with a onclick-event.
Problem:
The onclick-event got fired, when I call the plugin, without clicking
on the button.
Why got the click-event fired without clicking the button?
Here my (shorted) plugin:
(function($) {
$.fn.rte = function(options) {
$.fn.rte.defaults = {
button : {
bold : {
alt:' bold ',
// Problem: Got fired, before
I click on the Button!
click : function(){
alert('Bold!');
return false;
}
},
ul :{
alt:' ul ',
// Problem: Got fired, before
I click on the Button!
click : function(){
alert('UL!');
return false;
}
}
}
};
var opts = $.extend(true, $.fn.rte.defaults, options);
// iterate and construct the RTEs
return this.each(function(){
$.each(opts.button, function(i, n){
var button = $('<img />')
.attr(n);
$("#rtfButtons").append(button);
});
});
};
})(jQuery);