I have a lot of js files like new.js, index.js, create.js etc that handles my Ajax calls and other jquery code As the have many common code snippets I have tried to use partial js files For example I have a new.js file that calls a partial _new.js new.js <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb] %> _new.js <% if params[:group_id]%> $("#group_participants_content").html("<%= escape_javascript(render(:partial=>''form''))%>"); $(".remote_selected").removeClass("selected remote_selected simple-navigation-active-leaf"); $("#group_mail").addClass(" remote_selected simple-navigation-active-leaf"); <%else%> $("#users_content").html("<%= escape_javascript(render(:partial=>''form''))%>"); $(".remote_selected").removeClass("selected remote_selected simple-navigation-active-leaf") $("#mail").addClass("remote_selected simple-navigation-active-leaf"); <%end%> // Change our States History.replaceState({action:''<%= "#{controller.action_name}/#{controller_name}" %>''}, ''<%= "#{controller.action_name.titleize} #{controller_name}" %>'', ''?action=<%= "#{controller.action_name}/#{controller_name}" %>''); var url=History.getState().url; $("#help").attr(''href'',"/helps/0?url="+url) That works but to be useful I would like to add locals as <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], locals=>{id=>"#group_participants_content"}%> and change _new.js to $(''"''+id+''"'').html("<%= escape_javascript(render(:partial=>''form''))%>"); However that does not work- The js file seems then not to be loaded at all Anyone that has any suggestion of what is wrong ? Appreciate any help ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a4426ed5-8c18-4d0e-a3f4-0ded55b17889%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 28 July 2013 10:40, Hans <Hans.Marmolin-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org> wrote:> ... > > That works but to be useful I would like to add locals as > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], > locals=>{id=>"#group_participants_content"}%>I don''t know whether there are any other problems but it should be :locals and :id I think Colin> and change _new.js to > $(''"''+id+''"'').html("<%= escape_javascript(render(:partial=>''form''))%>"); > However that does not work- The js file seems then not to be loaded at all > > Anyone that has any suggestion of what is wrong ? > > Appreciate any help ? > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/a4426ed5-8c18-4d0e-a3f4-0ded55b17889%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsR6HxPJ4ZvEbt%2BQhNJpPjw0a62kdoFA7DcK-gXQAqa7A%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Den söndagen den 28:e juli 2013 kl. 11:40:09 UTC+2 skrev Hans:> > I have a lot of js files like new.js, index.js, create.js etc that handles > my Ajax calls and other jquery code > As the have many common code snippets I have tried to use partial js files > For example I have a new.js file that calls a partial _new.js > > new.js > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb] %> > > _new.js > <% if params[:group_id]%> > $("#group_participants_content").html("<%= > escape_javascript(render(:partial=>''form''))%>"); > $(".remote_selected").removeClass("selected remote_selected > simple-navigation-active-leaf"); > $("#group_mail").addClass(" remote_selected > simple-navigation-active-leaf"); > <%else%> > $("#users_content").html("<%= > escape_javascript(render(:partial=>''form''))%>"); > $(".remote_selected").removeClass("selected remote_selected > simple-navigation-active-leaf") > $("#mail").addClass("remote_selected simple-navigation-active-leaf"); > <%end%> > // Change our States > History.replaceState({action:''<%= > "#{controller.action_name}/#{controller_name}" %>''}, ''<%= > "#{controller.action_name.titleize} #{controller_name}" %>'', ''?action=<%= > "#{controller.action_name}/#{controller_name}" %>''); > var url=History.getState().url; > $("#help").attr(''href'',"/helps/0?url="+url) > > That works but to be useful I would like to add locals as > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], > locals=>{id=>"#group_participants_content"}%> > and change _new.js to > $(''"''+id+''"'').html("<%= escape_javascript(render(:partial=>''form''))%>"); > However that does not work- The js file seems then not to be loaded at all > > Anyone that has any suggestion of what is wrong ? > > Appreciate any help ? > > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1ca7abac-9e79-4fae-bf85-6afa2fe95223%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Den söndagen den 28:e juli 2013 kl. 11:40:09 UTC+2 skrev Hans:> > I have a lot of js files like new.js, index.js, create.js etc that handles > my Ajax calls and other jquery code > As the have many common code snippets I have tried to use partial js files > For example I have a new.js file that calls a partial _new.js > > new.js > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb] %> > > _new.js > <% if params[:group_id]%> > $("#group_participants_content").html("<%= > escape_javascript(render(:partial=>''form''))%>"); > $(".remote_selected").removeClass("selected remote_selected > simple-navigation-active-leaf"); > $("#group_mail").addClass(" remote_selected > simple-navigation-active-leaf"); > <%else%> > $("#users_content").html("<%= > escape_javascript(render(:partial=>''form''))%>"); > $(".remote_selected").removeClass("selected remote_selected > simple-navigation-active-leaf") > $("#mail").addClass("remote_selected simple-navigation-active-leaf"); > <%end%> > // Change our States > History.replaceState({action:''<%= > "#{controller.action_name}/#{controller_name}" %>''}, ''<%= > "#{controller.action_name.titleize} #{controller_name}" %>'', ''?action=<%= > "#{controller.action_name}/#{controller_name}" %>''); > var url=History.getState().url; > $("#help").attr(''href'',"/helps/0?url="+url) > > That works but to be useful I would like to add locals as > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], > locals=>{id=>"#group_participants_content"}%> > and change _new.js to > $(''"''+id+''"'').html("<%= escape_javascript(render(:partial=>''form''))%>"); > However that does not work- The js file seems then not to be loaded at all > > Anyone that has any suggestion of what is wrong ? > > Appreciate any help ? > > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e610f4cb-7ffb-4a9b-b51e-1501bac3c880%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Den söndagen den 28:e juli 2013 kl. 11:50:55 UTC+2 skrev Colin Law:> > On 28 July 2013 10:40, Hans <Hans.M...-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org <javascript:>> wrote: > > ... > > > > That works but to be useful I would like to add locals as > > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], > > locals=>{id=>"#group_participants_content"}%> > > I don''t know whether there are any other problems but it should be > :locals and :id I think > > Colin > > > > > > and change _new.js to > > $(''"''+id+''"'').html("<%= > escape_javascript(render(:partial=>''form''))%>"); > > However that does not work- The js file seems then not to be loaded at > all > > > > Anyone that has any suggestion of what is wrong ? > > > > Appreciate any help ? > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > > To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:>. > > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/rubyonrails-talk/a4426ed5-8c18-4d0e-a3f4-0ded55b17889%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out. > > > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fc20d343-7a14-41eb-8e2e-6f99ffef07ff%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Colin Thanks for your answere, but that was just a typo from me. The code has :locals and :id Den söndagen den 28:e juli 2013 kl. 11:50:55 UTC+2 skrev Colin Law:> > On 28 July 2013 10:40, Hans <Hans.M...-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org <javascript:>> wrote: > > ... > > > > That works but to be useful I would like to add locals as > > <%= render :partial=>''new'', :formats=>[:js],:handlers=>[:erb], > > locals=>{id=>"#group_participants_content"}%> > > I don''t know whether there are any other problems but it should be > :locals and :id I think > > Colin > > > > > > and change _new.js to > > $(''"''+id+''"'').html("<%= > escape_javascript(render(:partial=>''form''))%>"); > > However that does not work- The js file seems then not to be loaded at > all > > > > Anyone that has any suggestion of what is wrong ? > > > > Appreciate any help ? > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to rubyonrails-ta...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > > To post to this group, send email to rubyonra...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<javascript:>. > > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/rubyonrails-talk/a4426ed5-8c18-4d0e-a3f4-0ded55b17889%40googlegroups.com. > > > For more options, visit https://groups.google.com/groups/opt_out. > > > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/81bc6d43-d00b-40c0-9c85-0500d3cc7003%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On 28 July 2013 11:28, Hans <Hans.Marmolin-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org> wrote:> Colin > Thanks for your answere, but that was just a typo from me. The code has > :locals and :idWhen asking questions it is always a good idea to copy/paste then you are more likely to get helpful replies. Perhaps there are different typos in your code that you have accidentally corrected when you re-typed it here. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsG%2B6ZBNUXtj8PDqS4WsnoiCebZtPWHLdctG%2BCoDonr%3Dw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
The problem is now solved The correct use of locals should be $("<%=id%>").html("<%= escape_javascript(render(:partial=>''form''))%>"); and not $(''"''+id+''"'').html("<%= escape_javascript(render(: partial=>''form''))%>"); Den söndagen den 28:e juli 2013 kl. 12:56:19 UTC+2 skrev Colin Law:> > On 28 July 2013 11:28, Hans <Hans.M...-6LjvI5LOC4niH4Lt12DN6A@public.gmane.org <javascript:>> wrote: > > Colin > > Thanks for your answere, but that was just a typo from me. The code has > > :locals and :id > > When asking questions it is always a good idea to copy/paste then you > are more likely to get helpful replies. Perhaps there are different > typos in your code that you have accidentally corrected when you > re-typed it here. > > Colin >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aa4e815b-4ed3-4c3e-a381-78478eb54968%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.