From: <gem...@li...> - 2011-10-13 07:21:21
|
Revision: 96 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=96&view=rev Author: mennodekker Date: 2011-10-13 07:21:15 +0000 (Thu, 13 Oct 2011) Log Message: ----------- cancel old request when we make a new one, fixes problem in export when checking multiple boxes Modified Paths: -------------- trunk/new_project/htdocs/gems/js/autoSubmitForm.js Modified: trunk/new_project/htdocs/gems/js/autoSubmitForm.js =================================================================== --- trunk/new_project/htdocs/gems/js/autoSubmitForm.js 2011-10-12 13:14:19 UTC (rev 95) +++ trunk/new_project/htdocs/gems/js/autoSubmitForm.js 2011-10-13 07:21:15 UTC (rev 96) @@ -13,29 +13,29 @@ var self = this; /* - console.log(this.element); // Firebug console - console.log(this.options.submitUrl); // Firebug console + console.log(this.element); // Firebug console + console.log(this.options.submitUrl); // Firebug console console.log(this.options.targetId); // Firebug console */ // Bind the events - jQuery('input:text, select, textarea', this.element).keyup(function(e) {self.filter();}); - jQuery('select', this.element).change(function(e) {self.filter();}); - jQuery('input:checkbox, input:radio', this.element).click(function(e) {self.filter();}); + jQuery('input:text, select, textarea', this.element).keyup(function(e) {self.filter();}); + jQuery('select', this.element).change(function(e) {self.filter();}); + jQuery('input:checkbox, input:radio', this.element).click(function(e) {self.filter();}); // Set the initial value - this.lastQuery = this.value(); + this.lastQuery = this.value(); }, complete: function (request, status) { this.request = null; - + // Check for changes - // - if the input field was changed since the last request + // - if the input field was changed since the last request // filter() will search on the new value // - if the input field has not changed, then no new request // is made. - this.filter(); - }, + this.filter(); + }, destroy: function() { if (this.request != null) { @@ -46,18 +46,21 @@ filter: function () { + //If we have a pending request and want to create a new one, cancel the first + this.destroy(); + if (this.request == null) { // var name = this.options.elementName ? this.options.elementName : this.element.attr('name'); - + var postData = this.value(); - + if (this.options.targetId && this.options.submitUrl) { // Prevent double dipping when e.g. the arrow keys were used. if (jQuery.param(postData) != jQuery.param(this.lastQuery)) { this.lastQuery = postData; //console.log(postData); - + //* var self = this; this.request = jQuery.ajax({ @@ -70,20 +73,20 @@ }); // */ } - } + } } }, success: function (data, status, request) { jQuery(this.options.targetId).html(data); - }, + }, value: function () { return $(this.element[0]).serializeArray(); - }, + }, lastQuery: null, request: null -}); +}); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |