gpt4 book ai didi

jquery - 主干选项选择适用于 Firefox,但不适用于 Chrome

转载 作者:行者123 更新时间:2023-12-01 04:15:22 26 4
gpt4 key购买 nike

我正在使用 Backbone 处理选择框中选项的点击。由于某种原因,它可以在 Firefox 中运行,但不能在 Chrome 中运行。

这不是“using local files in Chrome ”问题,因为这一切都在我的服务器上运行。

在下面的代码片段中,FieldView 表示选择列表中的单个

var FieldView = Backbone.View.extend({
tagName: "option",

initialize: function () {
_.bindAll(this, 'render');
},
events: {
"click": "clicked"
},
clicked: function (e) {
var a_display_name = this.model.get("display_name");
var console_out = "selected " + a_display_name
console.log(console_out);
$("#fake_console").html(console_out);

},
render: function () {
this.$el.attr('value', this.model.get('COLUMN_NAME')).html(this.model.get('display_name'));
return this;
}
});

http://jsfiddle.net/thunderrabbit/QXAAW/3/

如何让它在 Chrome 中运行?

最佳答案

您应该使用更改jQuery docs .

要访问 FieldsView 集合中的模型,您可能应该通过向 FieldsView 添加事件来获取所选选项的索引:

events: {'change': 'optionChanged'},
optionChanged: function() {
var index = this.$el.children('option:selected').index();
var model = this.collection.at(index); // this is the model of the option view
}

关于jquery - 主干选项选择适用于 Firefox,但不适用于 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15262651/

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