在Rails中使用sortable.create时,如何实现在“onUpdate”方法中调用的函数

时间:2010-09-17 20:14:48

标签: ruby-on-rails ajax jquery-ui-sortable scriptaculous

我正在使用ROR创建一个应用程序,并且想知道如何在使用“sortable.create”时实现我想要调用的函数。

以下是我的“* .html.erb”文件中的示例代码。

<script type="text/javascript">
   Sortable.create("table_retain", {
      tag:"tr" , dropOnEmpty: true, onUpdate: function() { alert ('Updated!'); },
      containment:["table_aware","table_consider","table_acquire"], ghosting:true
   })
</script>

而不是“Alert”我想调用一个实际函数,在这种情况下我可以传递参数列表“table_retain”并在'Application Controller'中实现该函数。

我想知道如何做到这一点的语法。我是ROR的新手,非常感谢任何帮助。

由于

1 个答案:

答案 0 :(得分:0)

不确定我是否遗漏了一些东西,但你试过了吗?

<script type="text/javascript">
   Sortable.create("table_retain", {
      tag:"tr" , dropOnEmpty: true, onUpdate: function() { yourFunction("table_retain"); },
      containment:["table_aware","table_consider","table_acquire"], ghosting:true
   })
</script>