RubyHo (9) [Avatar] Offline
#1
In the Tags chapter of the book, the author uses this javascript in a template in the views/tags/remove.js.erb

$('#tag-<%= @tag.name.parameterize %>').remove();

Why is it necessary to put this in a template.js.erb file. I thought all javascript now went into the assets pipeline.

Please explain if you can. Thank you
RubyHo (9) [Avatar] Offline
#2
Re: Question about use of javascript in Tags chapter
speaking of the javascript, I can't get it to remove the tags, and I'm not getting any error messages in firebug.

this is the url it's sending when I click on a tag. Can anyone see a problem?


http://localhost:3000/projects/5/tickets/17?html[id]=...hod=delete&remote=true&url=/tickets/17/tags/2/remove
ryanbigg (423) [Avatar] Offline
#3
Re: Question about use of javascript in Tags chapter
How have you put this link in your view? The method and remote parameters in your example URL should not be there.
RubyHo (9) [Avatar] Offline
#4
Re: Question about use of javascript in Tags chapter
Thanks for the quick reply. I don't understand why my code is adding those extras

This is the code from remove.js.erb.

$('#tag-<%= @tag.name.parameterize %>').remove();


For what it's worth, here's the _tag.html.erb partial

<span class='tag' id='tag-<%= tag.name.parameterize %>'>

<% if can?(:tag, @ticket.project) || current_user.admin? %>
<%= link_to "x", <br /> :remote => true,
:url => remove_ticket_tag_path(@ticket, tag),
:method => :delete,
:html => { :id => "delete-#{tag.name.parameterize}" } %>
<% end %>
<%= tag.name %>
RubyHo (9) [Avatar] Offline
#5
Re: Question about use of javascript in Tags chapter
geez, you'd think Manning would have a forum that would allow formatting! hope this is better



this is the code from views/tags/remove.js.erb




$('#tag-<%= @tag.name.parameterize %>').remove();







the code below is from my _tag.html.erb partial



<span class='tag' id='tag-<%= tag.name.parameterize %>'>

<% if can?(:tag, @ticket.project) || current_user.admin? %>
<%= link_to "x", <br /> :remote => true,
:url => remove_ticket_tag_path(@ticket, tag),
:method => :delete,
:html => { :id => "delete-#{tag.name.parameterize}" } %>
<% end %>
<%= tag.name %>
RubyHo (9) [Avatar] Offline
#6
Re: Question about use of javascript in Tags chapter
Fixed now thank


<% if can?(:tag, @ticket.project) || current_user.admin? %>

<%= link_to "x", remove_ticket_tag_path(@ticket, tag), </br>
:remote => true,

:method => :delete,

:html => { :id => "delete-#{tag.name.parameterize}" } %>

<% end %>

<%= tag.name %>
RubyHo (9) [Avatar] Offline
#7
Re: Question about use of javascript in Tags chapter
that should say it's "fixed now thanks!"