Rails ajax jquery problem

Posted by user283179 on Stack Overflow See other posts from Stack Overflow or by user283179
Published on 2010-03-20T22:04:35Z Indexed on 2010/03/20 22:11 UTC
Read the original article Hit count: 385

Filed under:
|
|

Ok I have this problem I'm trying to use Jquery to load a partial in replace of a listed object.

loadshow:

$(function() {
    $(".style_image_<%= style.id %> a").click(function() {
    $(".style_image_<%= style.id %>").html("loading... ")
    $(".style_image_<%= style.id %>").html("<%= escape_javascript(render("show")) %>")
    $.get(this.href, null, null, "html");
    return false;
  });
});

_show.html.erb:

<%=link_to image_tag(style.cover.pic.url(:normal)), style %>

I'm getting this error:

missing ) after argument list
[Break on this error] $(".style_image_<%= style.id %>").htm...scape_javascript(render("show")) %>")\n

There is two problems with my code here the first is the click function is not targeting the .style_image_<%= style.id %> .... i.e (.style_image_42) if I replace the css target with 42 instead of _style.id the click target works; why is this?

And with or without this change the _show partial is not render and the above error is given.

Not really that good with Javascript any help would be great!

P.s.

The effect I really want is like one of those super cool cargo themes: http://cargocollective.com/publikspace

Thanks Dan!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery