Pulling in a form with ajax

Permalink
Hi all, I had a client request that they want a page built where
there were a few different buttons at the top which, when one is clicked on, a corresponding
form (made with advanced forms) would appear below it.

I get that normally I could do this with an ajax call but is this possible with pulling in various form blocks? What kind of php calls are involved with that?

Thanks,
Ed

growlrooed
View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
If you are on a 5.6.x core or earlier (not 5.7.x), you could set this up using my Blocks by AJAX addon can be used to do this, either by itself or in association with a stack pulling addon such as my Universal Content Puller.
growlrooed replied on at Permalink Reply
growlrooed
Hi John I was looking at that add on actually. Although I was a bit confused by how I set it up.

For example: say the page has 3-5 buttons on the page and each would call up a different form into a position below the buttons.

Doable?
JohntheFish replied on at Permalink Reply
JohntheFish
Yes. You would create a stack or hidden page for each form, then pull each of those into your page, then assign each a BBAX template.

You use one or more BBAX remote control block to set up the applicable behaviours and then add a trigger block for each button.

The triggers, remote control and BBAX templates are connected together with css selectors.

Before doing this, you should check the forms can happily coexist without the ajax. If there are already conflicts between the forms, ajax loading could suffer the same problem (or may actually help solve such problems). You also need to consider what happens after a form is submitted.

Having said all that, do you really need ajax loading of the forms? If they could all be loaded with the page, simple buttons+expanders may suffice, or an accordion or tabs (like my Magic Tabs addon provides), with either a tab design to look like your buttons, or hidden tabs and a selection of the Magic Tabs jump blocks to reveal.

My Magic Tabs addon can also be used with BBAX as the default BBAX behaviour is to ajax load when the block becomes visible, ie. when its tab or accordion opens.
growlrooed replied on at Permalink Reply
growlrooed
Thanks for the info.

You are right I was able to accomplish this with some very simple jquery scripting (show/hides more or less.)

Since the forms aren't overly complex it hasn't effected the page size too much.

But I will keep this addon in mind when I need to pull in more complex content.
For example I have a portfolio site coming up next month that could use this.

Thanks,
Ed