I have the following code:
$.getJSON('getAllTerminals.json', renderTerminalsOnMapAndFitBounds.bind({index:globalRequestCounter++, navigateToTypedText:true}))
...
function renderTerminalsOnMapAndFitBounds(data, updateSelectedTerminals) {
renderTerminalsOnMap.call(this,data);
fitBounds();
if(this.navigateToTypedText === true){
navigateMapToTypedAdress();
}
if (updateSelectedTerminals) {
$.getJSON('getSelectedTerminals', {}, function (json) {
window.MARC.addTerminalPage.terminalsSelected = json;
update();
initPage();
});
}
}
Can you advise me how to make that all works as now but to renderTerminalsOnMapAndFitBounds
was passed updateSelectedTerminals
as true ?
No, you cannot use
bind
to partially apply non-initial parameters (and there's noflip
). Just use a function expression:If you have to use bind, either change the parameter order of
renderTerminalsOnMapAndFitBounds
, or make it accept thatupdateSelectedTerminals
parameter as a property of thethis
object.