7
I’m working on a project that uses the library X-Editable with Bootstrap 3. Throughout the page are several instances of the plugin, however, there was a need for some instances to have a different template. Reading the library documentation I discovered that I can make the modifications through:
$.fn.editableform.buttons
But this ends up affecting all the other X-editables on the page. My question here is how I can make this change only for certain instances. There is how to extend this plugin and change this default behavior, being referenced as something like this:
$(selector).customEditable();
I don’t really know much about jQuery, what I have so far is this:
(function($){
$.fn.customEditable = function(options) {
// var defaults = {
editableform = {
buttons: '<button type="button" class="btn btn-primary btn-sm editable-trigger"><i class="glyphicon glyphicon-edit"></i></button>',
}
// };
var options = $.extend({}, editableform, options);
//Here you can create your extended functions, just like a base plugin.
return this.each(function() {
//Execute your normal plugin
$(this).editable(options);
console.log('customEditable');
});
};
})(jQuery);
But still I can’t do editableform.Buttons overwrite for this custom plugin!
see if this is http://jsfiddle.net/buh159/fGU58/23/ =D
– Brunno
But how could I make to have a xeditable different from the rest, without using $.fn.editableform.Buttons globally
– Nícolas Huber