0

我正在尝试在 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>

但是什么都没有发生,甚至没有错误消息。

我究竟做错了什么?

我不确定我是否可以在 Rhodes 上做到这一点,或者我是否应该以其他方式解决这个问题。

谢谢

4

1 回答 1

0

最后通过调用解决了:

<script type="text/javascript">

 $('.watchable').live('change', function() {

<!-- process you data here or whatever -->

  });

我的选择标签有一个名为 watchable 的类

于 2011-10-28T20:53:12.353 回答