动态组合和 mootools get 方法在 IE8 中不起作用
我在使用 Mootools get
方法和 IE8 时遇到问题。就是这样。
我有一个选择组合,可以使用 Request.HTML
HTML 动态加载选项:
<select name="model" id="model" class="customSelectModel">
<option>Modelo</option>
</select>
Javascript:
var req = new Request.HTML({
method: 'get',
url: loadModels,
data: "model="+model,
update: $('model'),
}).send();
此外,选择具有自定义样式,如下所示: http://vault.hanover.edu/~stilson/simpleselectstyle/
问题是当我加载 model
的内容时,IE 抛出一个错误:
对象不支持此属性或方法。
我不知道为什么,但
span.addEvent('change',function(){
span.set('text',this.options[this.options.selectedIndex].get('text'));
});
不适用于 IE8(通常,它与其他浏览器完美配合)。我正在使用 Mootools 1.3.2
有什么想法吗?多谢。
I have a problem with the Mootools get
method and IE8. This is the thing.
I have a select combo that loads dynamically the options with a Request.HTML
HTML:
<select name="model" id="model" class="customSelectModel">
<option>Modelo</option>
</select>
Javascript:
var req = new Request.HTML({
method: 'get',
url: loadModels,
data: "model="+model,
update: $('model'),
}).send();
Also, the select has a custom style, with this: http://vault.hanover.edu/~stilson/simpleselectstyle/
The problem is when I load the content of model
, IE throw me an error:
Object doesn't support this property or method.
I don't know why, but
span.addEvent('change',function(){
span.set('text',this.options[this.options.selectedIndex].get('text'));
});
does not work with IE8 (as usually, it works perfectly with the other browsers) . I'm using Mootools 1.3.2
Any ideas? Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法以跨浏览器的方式通过
innerHTML
更新我建议通过
onComplete: function() {}
进行重构,其中:model
的所有子元素,>model
model
的对象成员,并fireEvent("change")
突出显示您的新对象如果需要,请选择脚本编写选项。对于你的第二个问题。
this.options.get("value")
返回选定的值。如果是多项选择,则可以有超过 1 个值。
mootools 提供
selectel.getSelected()
它返回一个选项数组,您可以迭代以从中获取文本。因此:selectel.getSelected().get("text")
将返回["sometext"]
或["sometext1", "sometext2"] 进行多项选择。
you cannot update
<select>
elements content viainnerHTML
in a cross-browser fashion, which theupdate: $("model")
will try to do.I would suggest refactoring via an
onComplete: function() {}
where you:model
model
model
andfireEvent("change")
to highlight your new selected choice for scripting, if you need it.for your second question.
this.options.get("value")
returns selected value.if its a multiple select, it can have more than 1 value.
mootools provides
selectel.getSelected()
which returns an array of options you can iterate to get text from. hence:selectel.getSelected().get("text")
will return["sometext"]
or["sometext1", "sometext2"]
on a multiple select.