How to reload a div using render(:update) and replace_html?

后端 未结 3 1933
臣服心动
臣服心动 2021-01-06 22:43

How to reload only the div id on a page? I just need to reload a certain div.

in my controller I have

def mycontrolleraction
 ...

 render(:update) d         


        
相关标签:
3条回答
  • 2021-01-06 23:12

    use partials to update particular div in view

    render :partial => "fileame", :layout => false
    
    0 讨论(0)
  • 2021-01-06 23:18

    You can replace a div's content with a partial like this.

    render :update do |page|
      page.replace_html 'person-45', :partial => 'person', :object => @person
    end
    

    Where the div id is person-45 the partial's name is person. Also you can pass an object to your partial, in this case the object is @person. For more information please see the documentation.

    0 讨论(0)
  • 2021-01-06 23:31

    ref ajax-on-rails tutorial.To replace the html content of some div use replace_html

    render :update do |page|
      replace_html 'div', 'new refresh data'
    end
    
    0 讨论(0)
提交回复
热议问题