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() {
31 if (this.action.search('[\\?&]ajax=1') != -1)
33 if (this.action.search('\\?') != -1)
34 this.action += '&ajax=1';
35 else this.action += '?ajax=1';
37 $('form', hash.w).ajaxForm({
39 target: $('.target', $window),
40 success: function(response) {
41 if (response.success) {
42 $('.target', $window).text(response.message);
43 setTimeout(function() { $window.jqmHide() }, 1000);
44 if (response.redirect)
45 window.location = response.redirect;
48 $('.error', $window).remove();
49 $.each(response.errors, function(id, errors) {
50 $('#id_' + id, $window).before('<span class="error">' + errors[0] + '</span>');
52 $('input[type=submit]', $window).removeAttr('disabled');