views:

19

answers:

0

hi

I want to add a remote link via javascript(mootools). This code adds the link, but the click on this new link('delete foo 1') sends an html request and not an ajax request.

Why doesn't it send an ajax request? Can anyone help me.

Thanks

<div id="add_link"> add link </div>

<%= javascript_tag do %>
$('add_link').addEvents({
    'click': function(){
        var link = new Element('a',
         {
        'href' : '/foo/1',
        'data-remote' : 'true',
        'data-method': 'delete',
        'html': 'delete foo 1'
        });
     $('add_link').appendChild(link);
    }
});
<% end %>