// Alles laden initAllAjaxTools = function(){ initSelectOnchange(); initDefaultLink(); loadAjaxFlashNotice(); initDatePickers(); initAutoComplete(); } // initialisierung des Default Links initDefaultLink = function(){ // Default Ajax Link, formerly known as 'ajax_default_link'-Helper // Data will be automatically rendered into ajax overlay container, after showing loading message // add 'update-div-...' to set custom div to render data in! unloaded_links = $("a.<%= AJAX_DEFAULT_LINK %>.<%= AJAX_NOT_LOADED %>, form.<%= AJAX_DEFAULT_LINK %>.<%= AJAX_NOT_LOADED %>") unloaded_links.bind('ajax:beforeSend', function(xhr,settings) { link_options = linkOptionsFromClassName(this); if(link_options['hide_load_message'] != true){ if(link_options['load_message'] == true && link_options['target_div'] != ""){ ajaxLoadMessage(link_options['target_div'], link_options['load_message_text']); } else if(link_options['tiny_loader'] == true && link_options['target_div'] != ""){ tinyAjaxLoadMessage(link_options['target_div']); } else{ showLoading(); } }else if(link_options['push_progress_trigger'] != true){ handlePushProgress({'title': "Bitte warten...", "message": "Vorgang wird gestartet"}) } // Checking if data should be submitted if(link_options['submit_data'] != ''){ console.log("submitting: " + link_options['submit_data']) form_data = jQuery("#" + link_options['submit_data'] + " :input").serialize() console.log(form_data) console.log(settings.url) settings.data = form_data } }) // Default Ajax Link - Success unloaded_links.bind('ajax:success', function(xhr, data, status) { link_options = linkOptionsFromClassName(this); if(link_options['append'] == true){ $("#"+link_options['target_div']).append(data) } else{ $("#"+link_options['target_div']).html(data) } hideLoading(); initAllAjaxTools(); if(link_options['callback'] != ''){ eval(link_options['callback']); } }) // Default ajax link - Error unloaded_links.bind('ajax:error', function(xhr, status, error) { <% if Rails.env == 'development' %> flashNoticeDisplay("Error - see log for Details", 'error'); <% end %> hideLoading(); }); unloaded_links.removeClass("<%= AJAX_NOT_LOADED %>"); }