Two submit buttons – one submits on self, another submits into a popup
- Nox
- Member | 378
Since popup is dependant on JavaScript and considering posibility of displaying without CSS, in screenreader etc. so imho make this a presentation-only thing with progressive enhancement.
→ mark the submit with class/rel/data/whatever and then in JS you would copy it, assign it a handler (different one from the original submit if it used any). Perhaps you could use the data attribute so that you can pass a different title from the server, more useful in multilingual apps
Never much dealt with popups so 'm not sure if this “submitting into popup” is possible
- richard
- Member | 60
Sorry, I have no idea what is “make this a presentation-only thing with progressive enhancement” and how to “submit the form via AJAX and then open the popup”. A code example would do it.
<form>
<input type=submit onClick="setWhatToDoOnFormSubmit()"; value="1" />
<input type=submit onClick="setWhatToDoOnFormSubmit2()"; value="2" />
</form>
I know it is not going to be that simple…
Last edited by richard (2011-08-29 19:44)
- richard
- Member | 60
Just to particularize:
<script>
function setWhatToDoOnFormSubmit()
{
var form = document.getElementById("frm-form");
form.onSubmit ="window.open(...)";'
form.target = "preview";
}
</script>
I do not need to worry about javascript being off as this is intranet… But at worst it would submit on same window which is not too bad.
Last edited by richard (2011-08-30 06:48)
- richard
- Member | 60
For anyone who tries to follow up: after trying to implement this I found out that this is not very reliable solution. I ended up with setting new action in presenter. In this action I send javascript to the template. Something like this:
<?php
....
public function handleOpenPopup() {
... save form values to session first so you can use it in the popup
$this->template->additionalScript = 'window.open(...);'
}
?>
Last edited by richard (2011-09-12 04:58)