开发者

pass an object through jquery trigger

I'm trying to do something rather simple but I'm getting a strange result. I have an event trigger that I'm using to pass a json object but when it gets through to the other side it's a function... I alert the result and it shows this:

example of alert sting:

alert('value of lattitude? ' + map.curre开发者_如何学PythonntLatLng.lat);

result:

value of lattitude? function () {return this[a];}

I've tried setting up the trigger both with and without the array literal wrapper:

$('body').trigger('updateLocation', [{lat:38.905003, lng:-77.066497}]);
$('body').trigger('updateLocation', {lat:38.905003, lng:-77.066497});

What am I doing wrong?


Try this:

$('body').bind('updateLocation',function(event,obj){
    alert(obj.lng);
});

$('body').trigger('updateLocation', [{lat:38.905003,lng:-77.066497}]);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜