I'd love to help, but I have absolutely no idea what you're trying to do! I'd recommend starting with working code, then figure out how to organize and generalize it.
- Ben On Nov 25, 4:04 am, Lukáš <lukash...@gmail.com> wrote: > Hey, > > so after some time I decided to look into plugin creation. Since for > some time I was forced to load up to 30 different variables from > inputs, so I created a function that would read all the data from one > instead of multiple inputs. So now I tried to reform it into a plugin. > The problem starts here. > > Here is the code (simplified). > > (function($) { > $.datareader = function(settings) { > if(!settings) { > this.settings = $.extend({}, $.datareader.defaults, > settings); > } else this.settings = settings; > }; > > $.datareader.defaults = { > bracket: '{}' > } > > $.extend($.fn.dr, { > update: > function(input) { > process(this, false, 'update', input); > }, > del: > function(input) { > > }, > add: > function(input) { > > } > }); > > $.fn.dr = function(settings) { > this.each(function(settings) { > process(this, settings); > }); > > return this; > } > > })(jQuery); > > "process" function in does all the stuff needed since I need it > multiple times and returns an object. Now my question is about > "$.fn.dr". How can I force it to return a value instead of just > executing the function, I tried multiple ways but none of them worked. > Which would be fine for the functions that extend this one, since > there I need it to be executed instead of returing a value. Also I > dont really need the "$.fn.dr" function to loop trough all elements > since its only for my internal use, I know it will be fired only on > one. > > So to put it simple how can I force the function to return an actual > value? :) > > Oh and one more think. I create a "new $.datareader" object each time > its fired. Wouldnt that be a major slowdown or something if it will be > exucuted lets say 20 times? (which can easily happen) -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.