I could not stop the "onClick" event ? If i just use the dom node with the "onclick" event then dojo.stopEvent() works but not with the widget's "onClick". I am getting the error "Unable to load page ......status 0". I found out that this happens when the page refreshes while the Ajax call is being executed. I am posting my code. Any help is appreciated
// create a button which will be replaced by the Button widget
var submitButton = dojo.create('button', {type:"submit", id:"submitButton"}, popupFormControlDiv);
var popupFormSubmitButton = new dijit.form.Button({label: "Create", type:"submit"}, "submitButton");
dojo.connect(popupFormSubmitButton, "onClick", function(event) {
//Stop the submit event since we want to control form submission.
event.preventDefault();
event.stopPropagation();
dojo.stopEvent(event);
// construct the arguments for the post request
var xhrArgs = {
form: popupForm,
url: "/admin/sys-config/registration-form/add",
handleAs: "text",
load: function(data) {
console.log("success");
},
error: function(error) {
console.log("error");
}
}
var deferred = dojo.xhrPost(xhrArgs);
});