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

发布于 2024-09-24 02:22:24 字数 512 浏览 0 评论 0原文

我正在使用 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>

我想调用一个实际的函数,而不是“警报”,在本例中我可以向其传递参数列表“table_retain”并在“应用程序控制器”中实现该函数。

我想知道如何实现这一点的语法我是 ROR 新手,非常感谢您的帮助

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

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

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

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.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ懵逼小萝莉 2024-10-01 02:22:25

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

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文