« Return to Thread: [ANN] Licensing and support changes

Re: Pop up population, etc.

by aparajita :: Rate this Message:

Reply to Author | View in Thread

> It's pretty lame, but I have not ever tried to use javascript or any  
> other
> tools (AJAX; JSON; extjs) to be able to make a call back to fusebox  
> from a
> <select> that would then return data to populate a second <select>  
> on the
> same form.

There are plenty of examples out there on how to populate a select  
dynamically using JSON data. A quick google search for "populate  
select json" brings up lots.

As to how to return JSON data from Active4D/fusebox, there are several  
examples in the a4d.json chapter of the docs. You can also look at the  
demo site source code, I have a whole ExtJS Ajax-based demo there.

There is nothing magical about Ajax, as far as Active4D is concerned  
it is just another request from a browser. You can return HTML or  
JSON. If you return HTML, you can just replace the contents of an  
element on the page. If you return JSON, you have to write javascript  
code to iterate through the data and create the dom elements you want.

One important thing is to add the following code in all  
fbx_layouts.a4d in circuits that might handle an Ajax fuseaction:

// Don't use layouts with Ajax
if (request info{"X-Requested-With"} = "XMLHttpRequest")
        $fusebox{"layoutDir"}  := ""
        $fusebox{"layoutFile"} := ""
else
        $fusebox{"layoutDir"}  := "views/layouts"  // or wherever your  
layouts live
        $fusebox{"layoutFile"} := "lay_main.a4d"   // or whatever the  
appropriate layout is
end if


Regards,

    Aparajita
    www.aparajitaworld.com

    "If you dare to fail, you are bound to succeed."
    - Sri Chinmoy   |   www.srichinmoy.org

_______________________________________________
Active4D-dev mailing list
Active4D-dev@...
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

 « Return to Thread: [ANN] Licensing and support changes