0

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 %>
Jay
  • 6,206
  • 11
  • 48
  • 82

1 Answers1

0

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" %>
Jay
  • 6,206
  • 11
  • 48
  • 82