optimization - Render page rails, modal -


i trying optimize rendering page in ruby on rails.

i have question, there way make page, render page when link (href) associated clicked.

some codes in index.html.erb:

.....    ..... <h4>   <%= item.name %>   <br/><a href="#<%=itemt.id%>_item_modal">details</a> </h4>  <div id="<%=item.id%>_item_modal" class="modal fullscreen">   <div class="item-modal">     <%=render item%>   </div> </div> ..... .....    

in code above, using modal. when link clicked, _item.html.erb shown appear in smaller page. similar popup.

when index.html.erb loaded, codes inside _item.html.erb loaded automatically , queries inside executed because of

<%render item%>  

code.

what want is, don't want index.html.erb render item inside _item.html.erb page unless click "details" button.

<br/><a href="#<%=itemt.id%>_item_modal">details</a> 

i think doing think, can save amount of time when user requests item page, because system doesn't need retrieve information not yet required.

could guys me?

please let me know if need information.

you have use ajax in order achieve this. can create hidden div specific id, "modal".

revert h4 this:

<h4>   <%= item.name %>   <br/>   = link_to 'details', item_path(item), data: {remote: true}, item_details: true </h4> 

then in item controller, on show action:

def show   # load item   if params[:item_details]     respond_to {|format| format.js}   else     # here   end end 

and in item views folder, create file show.js(.coffee):

$('#modal').html('<%= j(render partial: "item", object: @item) %>'); $('#modal').modal('show'); 

this idea, have make compatible code.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -