You need to sign in to do that
Don't have an account?
Process jQuery 'change' event before VisualForce 'save' event from Button
Hi,
I have a VF page with a jQuery input field (actually a timepicker).
1) The NOK user scenario is the following : the user deletes the content of the input field and click immediately on the (VF) Save button. VF has to process 2 events : - updating the field in the data model (jQuery event), and saving the data model to the database (Visualforce-managed event).
Unfortunately, the Save event does not 'wait' for the update to take place : the saved data is not up to date.
2) The OK scenario is the following : the user deletes the content of the input field and click somewhere else in the page, then clicks on the Save button. The data is always correctly saved to the database.
How can I make sure, in scenario 1) that the data gets updated before being saved ?
Thanks for any help,
Rup
Hi Rupert,
I have seen the model before of preventing save until the js processing is done. You would need to disable the buttons on change and then in the change methods, re-enable the buttons when you are done processing. That should prevent the issue you are seeing.
Sorry, don't have any resources or demo code but happy to discuss further if you are stuck.
Nick
Great idea, Nick.
But I dont't really see how, in a jQuery callback, I could disable my VF Save button and rerender it (disabled) before doing my stuff, then re-enabling it and rerendering it again.
What do you think ?
Rup
I did a similar implementation here http://blogforce9.blogspot.in/2012/06/loadingwait-screen-using-jquery-ui.html . You may use the code to achieve the same
Hi Avi,
Thanks for your rapid response.
This is nearly exactly what I need. Instead of displaying an image while the UI is blocked, how can I disable the Save button ?
Rup
PS : nice Force.com demo gallery ! @ http://blogforce9dev-developer-edition.ap1.force.com/ProjectGallery
Hi Rupert,
Can you post some code here ?
Atleast the button and the jQuery Event part ?
Thanks
Avi
Set a Timeout Event on "Onclick" event of Save Button. Set the timer between 150 to 250ms randomly so that the trigger of controller funtion will be delayed for 2sec, which gives the JQuery a breathing time for updating the date.
onClick = "setTimeout('<actionfunction name>', 250)"