简体   繁体   中英

How to slide a form for create and edit in ruby on rails?

Is it possible to slide the form for Create and Edit in the same page of index without refreshing the page by using JavaScript without installing gem ? is it any example for this?

You need to have a unique html node in your page, for example,

<div id="main_content">
    #Any of your conntent will go here
</div>

And you links should have remote=>true .

Clicking on any link will request the create or edit form which will actually replace the content of the main_content div.

Here is reference that you can follow => http://www.alfajango.com/blog/rails-3-remote-links-and-forms/

You should find tons of resources on this in web. Let us know about any specific problem implementing the above.

Some More Help:

Update:

Ok. If you are completely beginner then it might seem a bit tough. Then I would suggest to break the whole things up into smaller achievable steps. And achieve one by one. Eventually you will be successful.

Here are the steps that I would recommend:

  1. Learning Remote Link
    • What is remote link
    • How to create these in rails 3.
    • Create a remote link yourself.
  2. Learning response handler
    • What is response handler in a controller.
    • How to handle ajax response.
    • What is the corresponding view file of a ajax request
  3. Writing *.js.erb file
    • Need to be familiar with javascript.
    • Need to know a basic of jquery.
    • Learn how to render a form in js.erb file
    • Set this form within a DIV of your main page.

I tried a make a simplest example of this. Find the codes here .

Share your problems of each step with us. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM