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

时间:2021-05-27 14:29:35

I am creating an application using ROR and would like to know how I can implement a function which I want to call when using "sortable.create".

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

Below is a sample code from my "*.html.erb" file.

下面是我的“* .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>

Instead of "Alert" I want to call a actual function to which I can pass the parameters in this case the list "table_retain" and implement the function in 'Application Controller".

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

I would like to know the syntax as to how this can be done. I am new to ROR and any help will be greatly appreciated.

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

Thanks

谢谢

1 个解决方案

#1


0  

Not sure if i'm missing something, but have you tried:

不知道我是否遗漏了什么,但你试过了吗?

<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>

#1


0  

Not sure if i'm missing something, but have you tried:

不知道我是否遗漏了什么,但你试过了吗?

<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>