views:

380

answers:

0

Hi,

I am using Rails (Facebooker). This is for Facebook apps (FBML) and to keep it simple, let's assume it's a student registration system.

In my student page (displaying their photo, name, grade etc), I have an 'edit' button. Clicking that button, will display a FB-dialog to edit their details.

My aim is simple. I want the user to be able to edit the details, click 'Save' (fb dialog button or submit_tag), and display the validation message in a placeholder ('Saved' OR 'Email must not be empty').

Currently, i have been able to achieve that. Except, the problem is, after save and close the dialog, my whole page is not yet being refreshed. So, when i click the 'edit' button again, all the original data still there (even though, it has been updated in database). It will only show the updated data once i refresh the whole page.

Questions.

  1. How to refresh the page after i click save or at least refresh just the dialog part?

  2. Any easier way to achieve what i want?

Thanks in advance.

This is part of my code:

<% remote_form_for @student,
        :url => student_url(:canvas => false),
        :success => "update_student(data)" do |f| %>
            <%= f.label :student_bio, "Bio:" %>
              <%= f.text_area "Bio" %>
        <p id="validation-message"></p>
        <%= f.submit "Save", :id => "button-save", :clickrewriteurl => student_url(@student, :canvas => false), :clickrewriteid => "validation-message" %>
     <% end -%>

    <% content_for :body_bottom do -%>
      <% javascript_tag do -%>
      function update_student(data)
      {
        var student = document.getElementById('validation-message');
        student.setInnerFBML(data["status"])
      }
      <% end -%>
    <% end -%>