Reputation: 36984
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 ?
Upvotes: 0
Views: 47
Reputation: 664548
No, you cannot use bind
to partially apply non-initial parameters (and there's no flip
). Just use a function expression:
$.getJSON('getAllTerminals.json', function(data) {
renderTerminalsOnMapAndFitBounds.call({
index:globalRequestCounter++,
navigateToTypedText:true
}, data, true);
});
If you have to use bind, either change the parameter order of renderTerminalsOnMapAndFitBounds
, or make it accept that updateSelectedTerminals
parameter as a property of the this
object.
Upvotes: 2