gpt4 book ai didi

php - 道场 : Unable to stop "onClick" dijit event

转载 作者:行者123 更新时间:2023-11-29 20:22:07 25 4
gpt4 key购买 nike

我无法停止 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);
});

最佳答案

我只是尝试了小部件和常规按钮,这两种方法都可以让按钮的点击处理程序停止提交表单的事件。

仅限 DOM:http://jsbin.com/inoyo4/edit

小部件:http://jsbin.com/ayomu4/edit

请注意,对于 DOM,我连接到 onclick,而对于小部件,我连接到 onClick。 dijit 经常使用驼峰式表示法,dijit 小部件包含许多事件 Hook ,这些事件钩子(Hook)映射到小部件内节点上的标准 DOM 事件(小写)。不幸的是,这可能会造成混淆。

您可能会发现这值得一读:http://docs.dojocampus.org/quickstart/events

关于php - 道场 : Unable to stop "onClick" dijit event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3465494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com