Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-3.1

Rails Ajax Or Javascript?


I was wondering which way would be the best for my following problem. and maybe sample on how to do it also

I have the following models: customer, music, books.

What I would like to do is when a customer wants to go into the edit page then automatically customer general information such as name, password show up! But on an other tab by pressing music which his another model then music information comes up in the same. Sorta like facebook and twitter edit page do it.

Now each of the form are rendered by the following code line at the moment

<%= render 'general'%>

but how do i include them in the link and should i just use javascript and toggle them or use ajax ?? Thanks


Solution

  • Well, this has little to do with Ajax, since all information you need aparently would already been loaded by you main customer object.
    What i understand you want is something like the tabs javascript plugin of twitter bootstrap: http://twitter.github.com/bootstrap/javascript.html#tabs
    You put the different content (music/books/etc) in different divs and when the tab is clicked, the content changes and the user gets a better experience.
    Take a look at the link, it is super easy to set up this plugin on your project.