Rhomobile 应用程序中选择的 onChange 事件
我试图在 Select 上触发 onChange 事件,但该事件没有被触发。
我的选择中有以下代码:
<select onchange="myEvent()" name="configuration[notifications_enabled]" id="configuration[notifications_enabled]" data-role="slider">
<option value="0" <%= "selected" if Integer(@configuration.notifications_enabled) == 0 %>>O</option>
<option value="1" <%= "selected" if Integer(@configuration.notifications_enabled) == 1 %>>|</option>
</select>
并且我的文件顶部有以下事件:
<script type="text/javascript">
function myEvent() {
<% app_info("inside the event") %>
}
</script>
当我第一次进入视图时,该消息显示在控制台上。但 当我更改选择按钮时,它永远不会再次打印。
我尝试了 onClick 事件,但它也不起作用。
我也尝试过:
<script>
$('#configuration[notifications_enabled]').change(function()
{
app_info('Value change to ' + $(this).attr('value'));
});
</script>
但没有任何反应,甚至没有错误消息。
我做错了什么?
我不确定我是否可以在罗德岛做到这一点,或者我是否应该以其他方式解决这个问题。
谢谢
I am trying to fire an onChange event on a Select, but the event is not being fired.
I have the following code in my select:
<select onchange="myEvent()" name="configuration[notifications_enabled]" id="configuration[notifications_enabled]" data-role="slider">
<option value="0" <%= "selected" if Integer(@configuration.notifications_enabled) == 0 %>>O</option>
<option value="1" <%= "selected" if Integer(@configuration.notifications_enabled) == 1 %>>|</option>
</select>
And I have the following event on the top of my file:
<script type="text/javascript">
function myEvent() {
<% app_info("inside the event") %>
}
</script>
The message shows up on the console when I first enter the view. But
when I change the select button it never gets printed again.
I have tried an onClick event instead, but it doesn't work either.
Also I have tried:
<script>
$('#configuration[notifications_enabled]').change(function()
{
app_info('Value change to ' + $(this).attr('value'));
});
</script>
But nothing happens, not even an error message.
What am I doing wrong?
I am not sure if I can do this on Rhodes, or if I should approach the problem some other way.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后通过调用解决了:
我选择的标签有一个名为 watchable 的类
Finally it was solved by calling:
where my select tags have a class named watchable