javascript - how to call event listener from the function which is in another scope? -
i want call google event listener looks this:
google.maps.event.addlistener(trucks[data.results[i].id], 'click', function() { // magic :) }
from function not defined in same scope:
function this:
function checkdata(){}
how can that? can somehow send value can same click value? mean needs work on click event want call normal well.
edit: let me more specific:
we have like:
function initialize() { google.maps.event.addlistener(trucks[data.results[i].id], 'click', function() {}; }
and in different scope have
function checkdata() { (var = 0; < window.data.results.length; i++) { if(window.data.results[i].driver_id==selectedindex) { // want sent founded object event handler in particular time } } }
what need put inside checkdata call event handler in time? how pass value it? or need pass value it?
revised answer:
google.maps.event
namespace contains trigger
method. can use method simulate (for example) click event on object. need reference object.
Comments
Post a Comment