I'm writing the wrong syntax, so the function is not getting called.
I'm making a jQuery function that just sends an AJAX call and redirects. But it doesn't actually apply to any selector.
my function
$.fn.update_and_return = function() {
$.ajax({type: "GET",
beforeSend: function(){
idx_var = $(".selected_adli").prevAll().length;
},
url: '#{organization_media_gallery_path(@organization, @gallery)}',
dataType: "script",
complete: function(){
$(".opened_photo").fadeOut(function(){
$(".adli").eq(idx_var - 1).addClass("selected_adli");
$(".media_lib").fadeIn();
});
}
});
}
How I instantiate it :
$.update_and_return();
Doesn't work. Why is that?