Re: Javascript with select in partial

Hassan Schroeder
Tue, 01 Sep 2009 02:12:59 -0000

Crap, sent previous by accident.

First, make sure you''re running Firebug with FF so you can see if
any JS errors are causing your script(s) to exit.

Second, in my simple test case I have the following:

<%= link_to_remote ''Get another opinion'',
  :url => {:action =>''opinion'', :method =>
''get''}, :update =>
''things/opinion'' %>
<%= render :partial => ''opinion'' %>

:: and the controller looks like:

  def opinion
    render :update do |page|
      page.replace ''opinion'', :partial =>
''opinion''
    end
  end

:: which reloads this simple partial:


  showing an opinion on <%= Time.now %>

  alert("hey!");



Each click on that "Get another opinion" link changes the partial view
(time changes) and JS executes.

Hopefully that''s some useful food for thought :-)

--
Hassan Schroeder ------------------------
hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
twitter: @hassan