问题描述
在过去的几个小时里,我一直在阅读有关此内容的帖子,并且开始认为DAL不能做到我需要做的事情,但是我正在用我的十二种不同的失败方法发表一篇文章试图弄清楚一些。
console.log("This always prints 1");
let selectElement = "select[name='show']";
let dalSpan = "#select2-id_show-container";
$(document).on("select2:select",selectElement,function() {
console.log("This never prints 1");
});
$(document).on("change",function() {
console.log("This never prints 2");
});
$(document).on("focus",function() {
console.log("This never prints 3");
});
$(selectElement).on("change",function() {
console.log("This never prints 4");
});
$(document).on("select2-select",function() {
console.log("This never prints 5");
});
$(document).on("select2-selecting",function() {
console.log("This never prints 6");
});
$(document).on("select2:select",dalSpan,function() {
console.log("This never prints 7");
});
$(document).on("change",function() {
console.log("This never prints 8");
});
$(document).on("focus",function() {
console.log("This never prints 9");
});
$(dalSpan).on("change",function() {
console.log("This never prints 10");
});
$(document).on("select2-select",function() {
console.log("This never prints 11");
});
$(document).on("select2-selecting",function() {
console.log("This never prints 12");
});
console.log("This always prints 2");
$(dalSpan).trigger("change"); // triggers 8 and 10
$(selectElement).trigger("change"); // triggers 2 and 4
您可以看到上面我尝试过的所有不同内容。在对选择元素本身或保存从DAL显示的值的范围进行更改时,这12个更改事件均不会真正触发。
我可以使用最后两行来触发所指示的更改功能,但它们实际上仍未响应任何内容,因此无法实现我想要的功能。
我意识到这个主题已经深入人心了,但是我已经反复解决了一个月之久,并且有点像我自己一样,否则使用DAL几乎不可能完成这个非常简单的JavaScript。>
我是否只需要卸载该库并学习执行此操作的新方法?我真的很喜欢它的功能,除了我需要以编程方式做出选择或做出选择时,这似乎根本不起作用。帮助吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)