seblavoie
12/14/2012 - 10:07 PM

auto-ajax.js

// Use to call views with self contained javascript function using backend
(function(){
  $("[data-ajax-url]:not(.disabled)").on("click", function(e){
    callAjaxScript(
      $(this).attr("data-ajax-url"), 
      $(this).attr("data-ajax-type") || "get", 
      $(this).attr("data-ajax-data") || "");
  });
})();

function callAjaxScript(url, type, data) {
  $.ajax({
    url: url,
    type: type,
    data: data || "",
    dataType: "script"
  });
}