how to add an argument to a method stored in an array that is called later
This is a follow-up to this question (although this is self-contained)
trying to `call` three methods but not working correctly with jQuery map.
I am trying to store a set of methods in an array but there is a set that
might have arguments like below (the initial methods are in before_methods
and the proposed methods are in lm_methods). I'm sure it's pretty self
explanatory what I want but I'd like to be able to merge in the arguments
into a reasonable call to f (specifically the arc.pLikedByTerm). I
currently have the following:
// signature
pLikedByTerm:function(term, ne, sw, m){
....
}
// code before_methods just to show
this.before_methods=[arc.pLocations,arc.pLikedLocations,arc.pLikedItems];
this.lm_methods=[arc.pLocations,arc.pLikedLocations,arc.pLikedItems,
arc.pLikedByTerm('surfing'),arc.pLikedByTerm('sailing')];
$.each(this.lm_methods, function(i,f){
f(ne,sw,m);
});
How would I do this or is this bad design? What would be the idiomatic
way? My brain is fried.
thx in advance
No comments:
Post a Comment