jQuery(function($) { $gp.notices.init(); $('#project_id').change(function() { var select = $(this); var project_id = $('option:selected', select).attr('value'); if ( !project_id ) { $('#submit').attr('disabled', 'disabled'); $('#preview').hide(); return; } $gp.notices.notice($gp_mass_create_sets_options.loading); select.attr('disabled', 'disabled'); $.ajax({type: "POST", url: $gp_mass_create_sets_options.url, data: {project_id: project_id}, dataType: 'json', success: function(data){ select.attr('disabled', ''); $gp.notices.clear(); if (data.added.length || data.removed.length) $('#submit').attr('disabled', ''); var preview = $('#preview'); preview.html('

Preview changes:

'); var preview_html = ''; preview_html += ''; preview.append(preview_html); preview.fadeIn(); }, error: function(xhr, msg, error) { select.attr('disabled', ''); msg = xhr.responsehtml? 'Error: '+ xhr.responsehtml : 'Error saving the translation!'; $gp.notices.error(msg); } }); }); $('#submit').attr('disabled', 'disabled'); $('#preview').hide(); });