2

I have a really strange situation in my actual javascript project. I created a custom event and put an array to this event

$.publish("merilon/TablesLoaded", getTables());

the object which subscribed this event didn't get with

$.subscribe("merilon/TablesLoaded", myfunc)

the two parameters event and the array in the function myfunc. Instead it get event and then each entry from the array as following parameter

so what i expectet is

myfunc(event, [obj1, obj2, obj3 ... objn]){...}

but i get

myfunc (event, obj1, obj2, obj3 ... objn){...}

I don't want a workaround. What i need is to understand why this happen and how i can prevent this. Anyone an idea?

4

1 回答 1

0

如上所述:

(function($)
 {
 var o = $({}); 
 $.each(
       { on : "subscribe", trigger : "publish", 
         off : "unsubscribe" }, 
         function(key, api)
           { 
           $[api] = function()
                       {
                       o[key].apply(o, arguments); 
                       } 
            }
       ); 
       })(jQuery);
于 2014-12-19T16:11:27.907 回答