Thank for all, it was usefull!
On dec. 10, 15:57, Rafał Pocztarski <r.pocztar...@gmail.com> wrote: > 2009/12/10 Imre Farkas <farkasimr...@gmail.com>: > > > > > Now when i call i do it so > > > <script type="text/javascript"> > > $(document).ready(function() { > > $("#progresbar-bar").hide(); > > $("#procent").hide(); > > $("#progresbar-bar").progresbar(procent=0,manual=false); > > }); > > </script> > > > My question: how can i make this to be a good writed structured > > plugin, and to call like > > > <script type="text/javascript"> > > $(document).ready(function() { > > $("#progresbar-bar").hide(); > > $("#procent").hide(); > > $("#progresbar-bar").progresbar({ > > procent:0, > > manual:false)}; > > </script> > > Instead of using positional arguments: > > function(procent_val, manual) { > var non_dinamic = manual; > var procent = procent_val; > ... > > } > > you can use an object to pass them by name: > > function(arguments) { > var non_dinamic = arguments.manual; > var procent = arguments.procent_val; > ... > > } > > By the way, when you call your function: > > .progresbar(procent=0, manual=false); > > you are also setting procent and manual variables in the local scope > of the caller. It is equivalent to: > > procent = 0; > manual = false; > .progresbar(procent, manual); > > What you probably wanted to do was just: > > .progresbar(0, false); > > When you use positional arguments you don't have to know their name. > When you use named arguments (using an object in JavaScript) you don't > have to remember their position and it's easier to add arguments > later, and it's also easier to call the function when some of them are > optional. > > Rafał Pocztarski