backbone.widget icon indicating copy to clipboard operation
backbone.widget copied to clipboard

Executing methods with parameters

Open nix4 opened this issue 11 years ago • 2 comments

JQuery widgets allows you to execute methods on the instance and pass parameters to those methods for example: $( "#elem" ).progressbar( "value", 40 ); will execute the 'value' and pass the 40 to the function.

How can I achieve the same with backbone.widget?

I noticed on:

https://github.com/meleyal/backbone.widget/blob/630dfca4abd9d9bc7fe88ca902f5821ed64b5794/backbone.widget.js#L45

that the method being executed on the widget is invoked but where are the parameters passed?

Is this not supported in backbone.widget?

Thanks

nix4 avatar Dec 01 '14 18:12 nix4

No, passing arguments is not currently supported. This should be pretty easy to add though if you'd consider making a pull request?

meleyal avatar Dec 02 '14 08:12 meleyal

I think we may not need this feature since there is a way of getting the widget instance. This is how I have I implemented what I needed:

var wgtInstance = $( "#elem" ).data( "progressbar" );
if(wgtInstance){
     wgtInstance.value(40);
}

nix4 avatar Dec 02 '14 14:12 nix4