【发布时间】:2010-08-12 07:17:17
【问题描述】:
我无法停止onClick 事件?
如果我只是将 dom 节点与onclick 事件一起使用,那么dojo.stopEvent() 可以工作,但不能与小部件的onClick 一起使用。
我收到错误 “无法加载页面 ... 状态 0”。我发现在执行 Ajax 调用时页面刷新时会发生这种情况。我正在发布我的代码。
任何帮助表示赞赏
// 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);
});
【问题讨论】:
标签: php javascript events dojo