I had a hyperlinks in the header. When user navigates from one header link to other i need to check whether page is in dirtied or not, if page is dirtied i need to show a modal which has ok and cancel buttons and on ok i need to navigate to the clicked header and on cancel i need to remain in the page. Below is the sample code I wrote.
Template:
<a href="#link1" id="link1"></a>
<a href="#link2" id="link1"></a>
HeaderView.js
..
..
ui {
"link1" : "#link1",
"link2" : "#link2",
},
events {
"click #link1" : "navigateLink1"
"click #link2" : "navigateLink2"
}
navigateLink1 : function(e) {
this.navigate(this.ui.link1, "#link1", true, e);
}
navigateLink2 : function(e) {
e.preventDefault();
this.navigate(this.ui.link2, "#link2", true, e);
}
navigate: function(uiElement, path, trigger, event) {
e.preventDefault();
if (model.isDirty() ) {
// I need to send a callback for clicking on ok button
this.callback = function() {
event.trigger();// I am getting an error saying that event.trigger is not a function.
}
new ApplicationModal(model: {callback: this.callback});
} else {
app.router.navigate(path , {trigger: trigger});
}
}
In ApplicationModal i am just executing the callback
I am getting an error saying that event.trigger is not a function while calling from the callback.Let me know how to navigate to the new page after e.preventDefault();