Saturday, 15 May 2010

ruby on rails - Javascript change src works on one page, not on the other -



ruby on rails - Javascript change src works on one page, not on the other -

i'm total noob, go easy on me.....

i have rails app, i'm letting users vote on links. when eligible vote, have image greenish thumb button. after vote, image changes white , increment number of votes. here's code:

var html = "<%= @link.votes_count + 1 %>"; var container = $("#link-<%= @vote.link.id %>"); container.find('.count').text(html) container.find('.thumb').attr('disabled', true) container.find('.thumb').attr('src', 'assets/thumb.png')

on index page, works perfectly. counter increases 1, button no longer votes , changes white thumb. on show page, it's using exact same lines of code. counter still increases 1, old image disappears, white thumb not show up. when @ console, index request works using image/png type of request, while show request doesn't using text/html request. it's inserting word links src. instead of /assets/thumb.png, it's using /links/assets/thumb.png. thoughts? thanks.

i think src relative, , should utilize absolute path.

like (in lastly line):

container.find('.thumb').attr('src', '/assets/thumb.png')

javascript ruby-on-rails

No comments:

Post a Comment