Hi Max, and Grey🙂
Its been a little while since ive been on, and to be fair I have been a little bit busy.
I have a unique one for you and I don't know if it can be done.
Basically I have a form opening up inside of (what is technically a lightbox) shadowbox. Now when the form is submitted I would prefer it if the shadowbox were to close automatically.
There is a control key attached to closing the shadow box and this is the letter c on your keyboard. So I wonder, is there anyway in which to have the form submit and then run a small script to emulate the pressing of the "c" key on a keyboard ?
Strange one I know.
Regards,
Tom.
Hi Fredrick,
Ive had a quick read and from the outset it looks like a heck of a mod for something small ?
Problem is (if I got the beginning of the thread right) I dont use JCE and neither do the people who will be using the site from an admin point of view. They prefer the default one, which kinda knackers things up a little.
I was hoping there may be a very simple snippet of code that could be placed within the form controls for on(AFTER) submit that it emulates the pressing of the C key on the keyboard as opposed to going and making modifications to the core files😟
Ultimately the modifications to core files would only make it harder in the long run to update and upgrade components and Joomla, which is something that needs to remain simple with as little backing up or modifications after the upgrade as possible.
Kind regards,
Tom.
I also forgot to ask,
You say the Form Tag Field ?
Im assuming the tab called Form Code? Then there are 4 fields, of which I can only imagine 2 would be valid. The on submit before sending mail and the on submit after sending email.
YOOlightbox then I assume?
You should use your link as usual on your pages; when clicked, YOOlightbox creates a new iframe and loads the new url within this. Looking closely, we see that in the parent document, there's a close link, with a javascript link calling Shadowbox.close(). This is what we wish to tap into from within our iframe...
So.. within our form, we first need to access the parent window "window.parent", and from within that, access the Shadowbox object and it's close() method. Thus, within our form, we need to make a js-call such as "window.parent.Shadowbox.close();". This could be attached to pretty much anything, but as we'd like this to fire as the form submits, either add it as an onsubmit event for the form, or let the "on submit (after email)" box generate the appropriate script.
Hope that wasn't too much to digest😉
Ohh, and the "Form tag" field is on the first tab in CC...
/Fredrik
Hi Fredrick,
Ok I think I am now seriously baffled🙂
Due to it being the Yoolightbox/shadowbox im assuming your earlier string wont work (well not on the form tag anyway).
So how do I edit this to get it to work, and where exactly would I put it.
Its been a long day really, and if I can get this to work before letting the site go live (although needing further info from other people) then i would be a happy bunny.
Many thanks,
Tom.
Hi Fredrik,
Ok,
I have tried both alternatives to see what the difference is and how they would work for me.
1st Option closes shadow box as planned upon clicking the submit button. But the email never arrived...
2nd Option Email arrived, but shadow box did not close, instead it redirected me to a page on my site with no main content in.
So both didn't work in their own unique way, and yet again both were successful.
Kind regards,
Tom.
Hi,
That sounds odd.. the mere loading of a new page within the iframe shouldn't affect the close() mechanism.
Having a too great value of setTimeout would indeed cause problems, as the DOM for the iframe gets destroyed as the new page loads, even so, that should not affect the parent window.
I'll try playing with this for a few days, and see what I come up with.
/Fredrik
Im not going to pretend im some javascript or php mastermind😉 as im not🙂
But from my view I can live with it shutting quickly provided it emails. Ive also been told by the powers that it is fine.
Then came the bombshell (just as I thought I was out of the woods), can we make sure that...
1. there are 2 email fields and if 1 doesn't match the other then it flags this up straight away
2. Phone numbers are checked to make sure they are a certain length
3. post codes match the standard UK format (hard to do I would imagine as the format changes depending on where you live)
Any ideas on any of these Fredrik ? Before I do a runner lol.
I think there was a topic regarding advanced validation the other day on the forum. How well this will play with lightbox/shadowbox is beyond my knowledge, I'm afraid.
This could, of course, be done using server-side validation. You would, however, have to drop the onsubmit="setTimeout" approach for this to be useful.
You could alter your onsubmit event, to run a custom (javascript) function. This should then do all the tests, posting notices whenever some test fails. Finally, it should either return true (to submit the form) and start the timer, or return false to stop the form from submitting.
Right now, I'm trying to convince the YOOeffects plugin to work with me - unfortunately with limited results. Might be that I'm using a non-YooTheme template... although I've followed their directions as to use with non-yoo template (loading mootools and such). I'll let you know once I've got around to test a few rough ideas..
/Fredrik
Hi Fredrik,
Ahh yes, good old Y00🙂
Most of the work is fantastic and invaluable in terms of the amount of time and effort it can save let alone the effects. But I find that support is a little slack. To say a person pays a subscription one would have thought that they would be willing to help as opposed to make it as hard as possible to get any kind of help. And when you finally give in and do everything you are asked (in terms of publishing all the details on a forum (albeit closed) they all disapear lol.
Still, as I say, the work is outstanding, just wished they would learn the support side and bug fix side of things from Max, Bob and everyone here🙂
Hi Fredrik,
The 'domready' event is MooTools specific so you'd need to have MooTools loaded in the shadow box to use it.
Bob
Hi Bob,
That I am aware of. Unfortunately, loading the mootools jslib did not help either, as you will find a few posts back. Thanks for your input though.
My best guess would be that the iframe DOM is considered part of the parent window DOM, and hence the domReady event has already fired. Nevertheless, the parent property would be available as soon as the window is created, so there's no real need to wait for the rest of the DOM to become available (as long as we don't do any advanced operations after the "on Submit - after email" code).
/Fredrik