When rendering the following partial, the <script> block isn''t getting rendered at all. Does rails strip this out or is it some limitation of the browser? <% remote_options = { :update => update, :with => "Form.serialize(''#{form}'')", :url => { :action => "process_multiple" } } %> <% do_before ||= nil %> <% click_fn = "on_#{form}_#{button}_clicked()" %> <script language="javascript"> function <%=click_fn%> { <%= do_before %> Form.getInputs(''<%=form%>'', null, ''<%=mode%>'')[0].value = ''<%=button%>''; <%= remote_function(remote_options) %>; return false; } </script> <% onclick ||= click_fn %> <%= image_tag("/images/tfs/en-#{button}.png", { :onclick => onclick, :name => "submit_#{button}", :width => "32px", :height => "32px", :onmouseover => "setStatusMessage(''#{button} files'');", :onmouseout => "setStatusMessage('''');" }) %>
Is the script code stripped out from the HTML output? Or are you doing this via ajax? afaik, inline javascript isn''t executed if you''re replacing innerHTML with content pulled via ajax. Martin DeMello wrote:> When rendering the following partial, the <script> block isn''t getting > rendered at all. Does rails strip this out or is it some limitation of > the browser? > > <% remote_options = { > :update => update, > :with => "Form.serialize(''#{form}'')", > :url => { :action => "process_multiple" } > } %> > <% do_before ||= nil %> > > <% click_fn = "on_#{form}_#{button}_clicked()" %> > <script language="javascript"> > function <%=click_fn%> { > <%= do_before %> > Form.getInputs(''<%=form%>'', null, ''<%=mode%>'')[0].value = > ''<%=button%>''; > <%= remote_function(remote_options) %>; > return false; > } > </script> > > <% onclick ||= click_fn %> > > <%= image_tag("/images/tfs/en-#{button}.png", { > :onclick => onclick, > :name => "submit_#{button}", > :width => "32px", > :height => "32px", > :onmouseover => "setStatusMessage(''#{button} files'');", > :onmouseout => "setStatusMessage('''');" > }) %> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
oh - yes, that would be it, then. oddly enough, i don''t need it any more because "onclick = if() { }" is working now! i have no idea why it wasn''t earlier, and was tearing my hair out trying to find a workaround for it. martin On 7/10/06, Inge J?rgensen <inge@manualdesign.no> wrote:> Is the script code stripped out from the HTML output? Or are you doing > this via ajax? > > afaik, inline javascript isn''t executed if you''re replacing innerHTML > with content pulled via ajax. > > Martin DeMello wrote: > > When rendering the following partial, the <script> block isn''t getting > > rendered at all. Does rails strip this out or is it some limitation of > > the browser? > > > > <% remote_options = { > > :update => update, > > :with => "Form.serialize(''#{form}'')", > > :url => { :action => "process_multiple" } > > } %> > > <% do_before ||= nil %> > > > > <% click_fn = "on_#{form}_#{button}_clicked()" %> > > <script language="javascript"> > > function <%=click_fn%> { > > <%= do_before %> > > Form.getInputs(''<%=form%>'', null, ''<%=mode%>'')[0].value > > ''<%=button%>''; > > <%= remote_function(remote_options) %>; > > return false; > > } > > </script> > > > > <% onclick ||= click_fn %> > > > > <%= image_tag("/images/tfs/en-#{button}.png", { > > :onclick => onclick, > > :name => "submit_#{button}", > > :width => "32px", > > :height => "32px", > > :onmouseover => "setStatusMessage(''#{button} files'');", > > :onmouseout => "setStatusMessage('''');" > > }) %> > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >