1

I have a checkbox that triggers a javascript function which shows/hides another component.

The problem is if I hit submit, but there is a required field missing the submit rerenders the page but doesnt retrigger the javascipt shows/hides. So some of the checkboxes that would show a different component will still be checked but the hidden component will still be hidden.

Is there a way to avoid re-rendering on submit, without using immediate=true because I still need validation?

3

Rather than looking for a way to change the way submit behaves you can address this in your JavaScript.

The basic idea is that as well as writing code that responds to events (such as checkbox changes) you also need to write code that is run when the page loads that applies the current state of the input fields (such as the checkbox) to the page. As well as addressing the submit problem, in the general case this allows the page to be used as an edit page and display correctly.

(I think you are talking about the whole page re-rendering; if you are using partial page rendering via reRender attributes, then there is also an oncomplete attribute that lets you run JavaScript to get the re-rendered part of the page directly displayed.)

  • Yah thats what I was thinking and looks like what Im going to have to do. I was just hoping there was a simpler solution because this will make the script much more complicated taking into account how many things render others. And since this code isnt for my eyes only and the rerendering isnt even a requirement I may just scrap it. – user2070057 Jul 30 '14 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.