jquery - How to make link to point to view? -


in application.html.erb file have links , <%= yield %>. want when link click, view rendered in <%= yield %> field without refreshing whole page.

so, started implementing ajax doing wrong , need help.

this did:

in webinars_controller.rb index method added format.js:

respond_to |format|   format.html   format.js   format.json { render json: @webinars } end 

then create index.js.erb file in /app/views/webinars/ folder:

$('.b-content-container').html("<%=j render @webinars %>"); 

and following how creating link in application.html.erb file:

but clicking on link interal serve error points me code in application.js:

// send request

// may raise exception actually

// handled in jquery.ajax (so no try/catch here)

xhr.send( ( s.hascontent && s.data ) || null );

in order fix issue, have use :template option of render render function specify template , :collection pass data current template.

> <%=j render template:'webinars/index' , collection:@webinars > %> 

this still fails, because in views folder have partial named: index.js.erb , somehow rails not able understand wanted rendered, need specify template extension too:

> <%=j render template:'webinars/index.html.erb' , collection:@webinars > %> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -