javascript - Arguments in callback function -
I have a small library, here is a function I use
is the piece of HashManager . Prototype.on = function (hash, callback) {if (hash [0] == '#') {hash = hash substr (1); } If (thus ... video [hash]! == 'object') {this.observers [hash] = []; } this. Posters [hash] Pushback (callback); Return to this.Bossers [hash] [this Porschors [hash] Length-1]; };
Here is my arrival
at ajaxURLS = {'# o_kompanii!': '/apages/about.html', '#product!': '/apages/production.html', '# gde_kupit!': '/apages/gde_kupit.html', '# hozyaike_na_zametku!': '/apages/hozyaike_na_zametku.html', '#News!': '/ Apages / News .html ',' # Contacts ':' /apages/contacts.html ',' # kurochka_po_zernyshku ':'! /apages/kurochka_po_zernyshku.html '};
And here's my loop
var hm = new window. HashManager (); $. Each (ajaxURLS, function (hash, uri) {HM.on (hash, function (uri, hash) {console.log (URI); console.log (hash);});});
My problem is that console.log always prints the value of my last key and my array, how can I correct the argument? Many thanks, best regards
can help you: / P>
var hm = new window. HashemManager (); $ .Each (ajaxURLS, function (_hash, _uri) {HM.on (_hash, (function (uri, hash) {console.log (URI); console.log (hash);}) (_heash, _uri)) ;});
Comments
Post a Comment