Can I stop the page from re-rendering after a form submission?

2010-04-14 Thread WhyNotSmile
I have a question which may be very basic - I'm not sure whether I've
just tied my brain in knots from thinking about it!  Apologies if so.

I have a form which has various buttons.  One of them is a 'Preview',
which pops up a new window (well, a PDF) when clicked.  At the moment,
there is some javascript going on, which enables and disables various
buttons when the page is loaded.  However, if the Preview button is
clicked, I don't want the page to reload afterwards, because it will
then apply these changes to the buttons, which I don't want...

Cake seems to insist that I have to go somewhere after form submission
(and for all the other buttons it does a reload of the current page,
which is fine), so is there a way to stop this from happening?

I hope that makes sense; I'm not sure I've explained it very well, but
as I say, my brain is confused!

Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.


Re: Can I stop the page from re-rendering after a form submission?

2010-04-14 Thread jacmoe
'onClick' = 'return false;' would do the trick I suppose. :)

On Apr 14, 1:02 pm, WhyNotSmile sharongilmor...@googlemail.com
wrote:
 I have a question which may be very basic - I'm not sure whether I've
 just tied my brain in knots from thinking about it!  Apologies if so.

 I have a form which has various buttons.  One of them is a 'Preview',
 which pops up a new window (well, a PDF) when clicked.  At the moment,
 there is some javascript going on, which enables and disables various
 buttons when the page is loaded.  However, if the Preview button is
 clicked, I don't want the page to reload afterwards, because it will
 then apply these changes to the buttons, which I don't want...

 Cake seems to insist that I have to go somewhere after form submission
 (and for all the other buttons it does a reload of the current page,
 which is fine), so is there a way to stop this from happening?

 I hope that makes sense; I'm not sure I've explained it very well, but
 as I say, my brain is confused!

 Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.


Re: Can I stop the page from re-rendering after a form submission?

2010-04-14 Thread Andy Dirnberger
Cake doesn't insist on anything. The nature of clicking a submit
button in a form is to submit the form. That means the browser sends
the post/get request to the server and loads the response. If you want
different behavior, you need to catch the submit event through
JavaScript and cancel it.

The most basic way is form ... onsubmit=return false;, although
this would block all submissions. You can do onsubmit=return
someFunction(); and have someFunction return true if you want to
submit the form, and return false if you don't. Or you can use a
library, like jQuery, and do something along the lines of $
('form').submit(function(e) { ... }); and conditionally call
e.preventDefault() if you don't want to submit the form.

You can also look into Cake's JavaScript helper.

On Apr 14, 7:02 am, WhyNotSmile sharongilmor...@googlemail.com
wrote:
 I have a question which may be very basic - I'm not sure whether I've
 just tied my brain in knots from thinking about it!  Apologies if so.

 I have a form which has various buttons.  One of them is a 'Preview',
 which pops up a new window (well, a PDF) when clicked.  At the moment,
 there is some javascript going on, which enables and disables various
 buttons when the page is loaded.  However, if the Preview button is
 clicked, I don't want the page to reload afterwards, because it will
 then apply these changes to the buttons, which I don't want...

 Cake seems to insist that I have to go somewhere after form submission
 (and for all the other buttons it does a reload of the current page,
 which is fine), so is there a way to stop this from happening?

 I hope that makes sense; I'm not sure I've explained it very well, but
 as I say, my brain is confused!

 Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.


Re: Can I stop the page from re-rendering after a form submission?

2010-04-14 Thread WhyNotSmile
Thanks everyone.  I figured it out - I created the view page to
generate the PDF, which then pops up automatically and leaves the old
view in place.

Thanks again.

On Apr 14, 3:42 pm, Andy Dirnberger andy.dirnber...@gmail.com wrote:
 Cake doesn't insist on anything. The nature of clicking a submit
 button in a form is to submit the form. That means the browser sends
 the post/get request to the server and loads the response. If you want
 different behavior, you need to catch the submit event through
 JavaScript and cancel it.

 The most basic way is form ... onsubmit=return false;, although
 this would block all submissions. You can do onsubmit=return
 someFunction(); and have someFunction return true if you want to
 submit the form, and return false if you don't. Or you can use a
 library, like jQuery, and do something along the lines of $
 ('form').submit(function(e) { ... }); and conditionally call
 e.preventDefault() if you don't want to submit the form.

 You can also look into Cake's JavaScript helper.

 On Apr 14, 7:02 am, WhyNotSmile sharongilmor...@googlemail.com
 wrote:

  I have a question which may be very basic - I'm not sure whether I've
  just tied my brain in knots from thinking about it!  Apologies if so.

  I have a form which has various buttons.  One of them is a 'Preview',
  which pops up a new window (well, a PDF) when clicked.  At the moment,
  there is some javascript going on, which enables and disables various
  buttons when the page is loaded.  However, if the Preview button is
  clicked, I don't want the page to reload afterwards, because it will
  then apply these changes to the buttons, which I don't want...

  Cake seems to insist that I have to go somewhere after form submission
  (and for all the other buttons it does a reload of the current page,
  which is fine), so is there a way to stop this from happening?

  I hope that makes sense; I'm not sure I've explained it very well, but
  as I say, my brain is confused!

  Thanks!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using remove me as the subject.