views:

59

answers:

1

How can i render a partial inside a tag on the clicking of a href tag.

<a href = "#" class= "addWidget" value = "Add Widget">add</a>
<script type="text/javascript">
  $(".addWidget").click(function(){
  <%= render :partial => 'form'%>
  });
</script>
+2  A: 

If you want to embed the partial content, you could simply:

$('.addWidget').click(function(){
    $(this).append("<%= render :partial => 'form'%>");
});

Note that the html of your <%= render ...%> code needs to be quoted in the Javascript - here I've done so with double quotes, but whether double or single, be sure to escape them in the rendering of the partial.

Chadwick
@chadwick : -Thanks. It worked.
Silver Spoon