PDA

View Full Version : Button disable before page submit



ajain
24 Apr 2009, 5:54 AM
Hi,

I have a grid that has a save button. Grid is populated with json data. On click of save, I am setting the json data into a hidden form field and then submitting the form. If the json data is too large, the setting of hidden form field takes some time and during that period it appears as if the page is frozen. In order to let the user know that the save button click has already been fired, I was trying to disable the save button on click of save. I am adding the code to disable the button before setting json data to hidden field. However the button does not get disabled till the page is submitted. What could be the reason for this? Is there a workaround?



{
text: 'Save',
id: 'saveBtn',
handler: function() {
Ext.getCmp('saveBtn').disable();
document.getElementById('dataList').value=Ext.util.JSON.encode(results.censusRoot);
document.jsonForm.action ='censusUpload.do?census_action=save';
document.jsonForm.submit();
}
}

jay@moduscreate.com
24 Apr 2009, 6:07 AM
why disable the button if you're doing a plain'ol submit?

jay@moduscreate.com
24 Apr 2009, 6:08 AM
btw, we do have *help sections.

ajain
24 Apr 2009, 6:12 AM
Like I said, between the time the json data is getting populated in the hidden field and the page is submitted, the page seems to do nothing and it feels like the page has hung. So I wanted to either disable the save button or mask the page to let the user know that the request to save has already been invoked.

jay@moduscreate.com
24 Apr 2009, 6:21 AM
how about deferring the execution of the population of the hidden field by 100ms. give the UI time to update.

ajain
24 Apr 2009, 8:21 AM
Worked, thanks!