Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Newbie: reaching js file from controller

ajax

  • Please log in to reply
No replies to this topic

#1 pbdq

pbdq

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 06 January 2012 - 07:06 AM

Hi!
I've been struggling with a ajax/jquery html fraction update for a couple of days now, can't seem to get my head around it.
I can't get my update.js.erb file to run, this is how my relevant files look like:

The view:
<div id="menuwrapper">
      <div class="tabArea">
         <%= link_to 'Link', {:action => 'update', :controller => 'welcome'},{:class=>"tab",:remote=>true} %>
      </div>
</div>
<div id="wrapper2">
    <!-- Where I want the html fragment-->
</div>




Welcome_controller:
def update
    respond_with do |format|
        format.js
    end
end


Route:
get "welcome/update"

update.js.erb:
$('#wrapper2').html("<%= escape_javascript render(:file => 'c.html.erb') %>");


Would appreciate any help I could get! This is the fourth forum I'm trying my luck in and hopefully the last! I'm about to lose it..

Thank you.

/Peter
  • 0