是否可以在observe_field帮助器中放置一个条件?

发布于 2024-10-01 18:31:37 字数 615 浏览 1 评论 0原文

使用观察字段助手,我正在保存数据并使旋转器在更新时可见。另外,我想更新一个div。可以用observe_field helper 中的条件来完成吗?

<%= observe_field 'act_feb',
    :url => { :controller => :prep, :action => :toggle_feb },
    :method => :put,
    :loading => "$('feb_spinner').setStyle({visibility: 'visible'});",
    :complete => "$('feb_spinner').setStyle({visibility: 'hidden'});",
    :with => "'feb=' + $('act_feb').value",

    if $('team_feb').value == true
        "$('jan_reminder_').setStyle({visibility: 'visible'});"
    else
        "$('jan_reminder_').setStyle({visibility: 'hidden'});"
    end %>

using an observe_field helper, i am saving data and making a spinner visible while updating. in addition, i would like to update a div. could it be done with a condition inside the observe_field helper like so?

<%= observe_field 'act_feb',
    :url => { :controller => :prep, :action => :toggle_feb },
    :method => :put,
    :loading => "$('feb_spinner').setStyle({visibility: 'visible'});",
    :complete => "$('feb_spinner').setStyle({visibility: 'hidden'});",
    :with => "'feb=' + $('act_feb').value",

    if $('team_feb').value == true
        "$('jan_reminder_').setStyle({visibility: 'visible'});"
    else
        "$('jan_reminder_').setStyle({visibility: 'hidden'});"
    end %>

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

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

发布评论

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

评论(1

走走停停 2024-10-08 18:31:38

我可以看到它位于错误的位置。如果我把它放在“:complete”后面怎么办?

<%= observe_field 'act_feb',
    :url => { :controller => :prep, :action => :toggle_feb },
    :method => :put,
    :with => "'feb=' + $('act_feb').value",
    :loading => "$('feb_spinner').setStyle({visibility: 'visible'});",
    :complete => "$('feb_spinner').setStyle({visibility: 'hidden'});
    if $('team_feb').value == true
        $('jan_reminder_').setStyle({visibility: 'visible'});
    else
        $('jan_reminder_').setStyle({visibility: 'hidden'});
    end" %>

I can see that it was in the wrong location for this. What if i placed it following ":complete"?

<%= observe_field 'act_feb',
    :url => { :controller => :prep, :action => :toggle_feb },
    :method => :put,
    :with => "'feb=' + $('act_feb').value",
    :loading => "$('feb_spinner').setStyle({visibility: 'visible'});",
    :complete => "$('feb_spinner').setStyle({visibility: 'hidden'});
    if $('team_feb').value == true
        $('jan_reminder_').setStyle({visibility: 'visible'});
    else
        $('jan_reminder_').setStyle({visibility: 'hidden'});
    end" %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文