Struggling a bit with rendering a partial in an RJS template. I''m having to feed the javascript directly to the page object as couldn''t find a way to have insert_html work directly on the proxy object returned by select. However, that''s not the problem. The code for doing that is below and it all works fine, except that a new line is being inserted after the partial and before the final single quote, which means the string isn''t terminated. It''s definitely not in the partial, which is a simple one-line: <li><%= #stuff %></li> page << "first_item = $$(''#rant_list li'').first(); new Insertion.Before first_item, ''#{render(:partial => ''rant_list_item'', :object => @rant)}'';" Anybody got any ideas why it''s doing this?
Oddly, this works fine if I cut and paste the partial and do a render :inline with the cut and pasted code Chris T wrote:> Struggling a bit with rendering a partial in an RJS template. I''m > having to feed the javascript directly to the page object as couldn''t > find a way to have insert_html work directly on the proxy object > returned by select. > > However, that''s not the problem. The code for doing that is below and > it all works fine, except that a new line is being inserted after the > partial and before the final single quote, which means the string > isn''t terminated. It''s definitely not in the partial, which is a > simple one-line: <li><%= #stuff %></li> > > page << "first_item = $$(''#rant_list li'').first(); new > Insertion.Before first_item, ''#{render(:partial => ''rant_list_item'', > :object => @rant)}'';" > > Anybody got any ideas why it''s doing this? > >
Anyone? Chris T wrote:> Oddly, this works fine if I cut and paste the partial and do a render > :inline with the cut and pasted code > > Chris T wrote: >> Struggling a bit with rendering a partial in an RJS template. I''m >> having to feed the javascript directly to the page object as couldn''t >> find a way to have insert_html work directly on the proxy object >> returned by select. >> >> However, that''s not the problem. The code for doing that is below and >> it all works fine, except that a new line is being inserted after the >> partial and before the final single quote, which means the string >> isn''t terminated. It''s definitely not in the partial, which is a >> simple one-line: <li><%= #stuff %></li> >> >> page << "first_item = $$(''#rant_list li'').first(); new >> Insertion.Before first_item, ''#{render(:partial => ''rant_list_item'', >> :object => @rant)}'';" >> >> Anybody got any ideas why it''s doing this? >> >> > >
OK. Refactored the problem out by arranging my divs differently. Still, puzzling... Chris T wrote:> Anyone? > > Chris T wrote: >> Oddly, this works fine if I cut and paste the partial and do a render >> :inline with the cut and pasted code >> >> Chris T wrote: >>> Struggling a bit with rendering a partial in an RJS template. I''m >>> having to feed the javascript directly to the page object as >>> couldn''t find a way to have insert_html work directly on the proxy >>> object returned by select. >>> >>> However, that''s not the problem. The code for doing that is below >>> and it all works fine, except that a new line is being inserted >>> after the partial and before the final single quote, which means the >>> string isn''t terminated. It''s definitely not in the partial, which >>> is a simple one-line: <li><%= #stuff %></li> >>> >>> page << "first_item = $$(''#rant_list li'').first(); new >>> Insertion.Before first_item, ''#{render(:partial => ''rant_list_item'', >>> :object => @rant)}'';" >>> >>> Anybody got any ideas why it''s doing this? >>> >>> >> >> > >