function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
@altius_rup@altius_rup 

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

Nick WhitneyNick Whitney

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

@altius_rup@altius_rup

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

Avidev9Avidev9
Rupert you can have a look at jQuery UI block to block the UI while a background process is running.

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
krish99krish99

Hi,,

 

          i am working with service console app.. when customer click on chat button means automatically chat box is open at that time visualforce page must be lock..and after some the vf page must be unlock how can i achieve this..

@altius_rup@altius_rup

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

Avidev9Avidev9

Hi Rupert,

Can you post some code here ?

Atleast the button and the jQuery Event part ?

 

Thanks

Avi

SF_GuhaSF_Guha

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)"