I want to modify the javascript from an ASP.NET MVC 4 template website so that the dialogs that comes with the template to login/register actions could be used in any link that had an ".ajax-link" class in my code. So I did some changes in AjaxLogin.js that now looks like this:
//...
$('.ajax-link').each(function () {
    $(this).click(function (e) {
        var link = $(this),
            url = link.attr('href');
        var separator = url.indexOf('?') >= 0 ? '&' : '?';
        $.get(url + separator + 'content=1')
        .done(function (content) {
            var dialog = $('<div class="modal-popup"">' + content + '</div>')
                .hide() // Hide the dialog for now so we prevent flicker
                .appendTo(document.body)
                .filter('div') // Filter for the div tag only, script tags could surface
                .dialog({ // Create the jQuery UI dialog
                    dialogClass: 'fi-dialog',
                    title: link.data('dialog-title'),
                    modal: true,
                    resizable: false,
                    draggable: true,
                    width: link.data('dialog-width') || 600,
                    beforeClose: function () { resetForm($(this).find('form')); }
                })
                .find('form') // Attach logic on forms
                    .submit(formSubmitHandler)
                .end();
            dialog.dialog('open');
        });
        // Prevent the normal behavior since we use a dialog
        e.preventDefault();
    });
});
//...
And then I add the attribute class="ajax-link" in all the links I want to be shown in an jQuery dialog.
But it's not working. Actually the dialog opens only to the FIRST link I click inside the page, and after I close the dialog I can click in any other link that it won't appear. What I'm doing wrong here?
 
     
     
    