Alex,

Same issue I had some time ago:
https://github.com/twitter/bootstrap/pull/989

Danilo

Em 04/02/2012, às 16:03, Alex <[email protected]> escreveu:

> I figured out how to do this and realized that part of my problem is
> that there is no standard way to pass arguments into the plugin
> methods if one wants to extend a method.  For example, changing the
> function for the modal as below (adding the arg functionality), allows
> me to extend the standard plugins with methods that accept additional
> parameters.  Obviously, I can simply fork the existing code, but I
> wonder if:
> 
> a) there is a better way to do what I want (I am new to plugins so I
> may be missing something obvious)
> b) if this type of code could be added to all plugin functions so that
> they can be more easily extended without having to modify the plugin
> code.
> 
>  $.fn.modal = function (option) {
>    var args = arguments[1] || {}; // capture the arguments passed in
>    return this.each(function () {
>      var $this = $(this)
>        , data = $this.data('modal')
>        , options = typeof option == 'object' && option
>      if (!data) $this.data('modal', (data = new Modal(this,
> options)))
>      if (typeof option == 'string') data[option](args)  // pass in
> the args
>      else data.show()
>    })
>  }
> 
> On Feb 2, 11:00 am, Alex <[email protected]> wrote:
>> I would like to add some functionality to the Bootstrap plugins
>> without actually modifying the plugins.  I am new to working with
>> JQuery plugins and quite get it to work.  My code looks like this:
>> 
>>   $.extend($.fn.modal, {
>>         showFooterMessage: function (message) {
>>             alert("Hey");
>>         }
>>     });
>> 
>>   $(this).closest(".modal").modal("showFooterMessage");
>> 
>> But the error is that the object has no showFooterMessage so obviously
>> I am extending it incorrectly.  Can anyone suggest the appropriate
>> approach?
>> 
>> Thanks,
>> Alex

Reply via email to