4 // create containers for all ajaxable form links
5 $('.ajaxable').each(function() {
6 var $window = $("#ajaxable-window").clone();
7 $window.attr("id", this.id + "-window");
8 $('body').append($window);
10 var trigger = '#' + this.id;
12 var href = $(this).attr('href');
13 if (href.search('\\?') != -1)
15 else href += '?ajax=1';
19 ajaxText: '<p><img src="' + STATIC_URL + 'img/indicator.gif" alt="*"/> ' + gettext("Loading") + '</p>',
20 target: $('.target', $window)[0],
23 onShow: function(hash) {
24 var offset = $(hash.t).offset();
25 hash.w.css({position: 'absolute', left: offset.left - hash.w.width() + $(hash.t).width(), top: offset.top});
26 $('.header', hash.w).css({width: $(hash.t).width()});
29 onLoad: function(hash) {
30 $('form', hash.w).each(function() {this.action += '?ajax=1';});
31 $('form', hash.w).ajaxForm({
33 target: $('.target', $window),
34 success: function(response) {
35 if (response.success) {
36 $('.target', $window).text(response.message);
37 setTimeout(function() { $window.jqmHide() }, 1000)
40 $('.error', $window).remove();
41 $.each(response.errors, function(id, errors) {
42 $('#id_' + id, $window).before('<span class="error">' + errors[0] + '</span>');
44 $('input[type=submit]', $window).removeAttr('disabled');