AJAX, tab interface and FORMS

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

AJAX, tab interface and FORMS

Post by VladSun »

I participated in one project - web-based application for integrating CRM with a call-center (Asterisk based). It's extremely AJAX based with tab interface. I made a Javascript framework for it by using jQuery, but I faced a problem with targeting FORMs:
by submitting a form, there are optionally several tabs to be refreshed. So, I added hidden fields in every form like these:

Code: Select all

 <input type='hidden' class='tabControl' name='refresh' value='tab_name_goes_here' disabled='1'><input type='hidden' class='tabControl' name='close' value='tab_name_goes_here' disabled='1'><input type='hidden' class='tabControl' name='open' value='tab_name_goes_here' disabled='1'> 
i.e. the name parameter is for "action", and the value parameter is for "tab target". The default FORM submit is cancelled, but instead an AJAX POST is performed.

I wonder whether some of you have been facing this problem and what solutions do you have?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: AJAX, tab interface and FORMS

Post by pickle »

I'm not 100% sure on what you're asking. Do you want a way to reload the appropriate tab after a form is submitted?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: AJAX, tab interface and FORMS

Post by VladSun »

Let's have an example:
There is a tab containing the users list - "User list". There is a button "Add user" in this tab. When submitting the form containing this button, a new tab "Add user" is opened and focused. This new tab has its own form for filling the information and when it is submitted there are two actions to be executed - the response of is targeted to this "Add user" (i.e. successful or not) and at the same time the "User list" tab is refreshed. Supposing we have successfully created an user, there is an "OK" button, which when clicked performs two actions - closes the current "Add user" tab and focuses the "User list" tab.

PS: You can always select and view any tab, any time ...
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: AJAX, tab interface and FORMS

Post by pickle »

So...you want to be able to somehow know which tabs to refresh (via AJAX) based on which button was pressed?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: AJAX, tab interface and FORMS

Post by VladSun »

No :)
I have solved it in the way I described.
I just want to know if there is somebody that faced this problem and how did he solve it.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply