Wednesday, November 24, 2010

Re: AJAX Chain Reaction - Multiple Divs.

Cool, I think I understand a bit better now.

At the moment, you initially only display one <select> list, and then
based on that, you show other <select> lists. But what you want, is to
show all the lists always, and just change the options available, the
<label> of the lists, and potentially hide some lists. Does that sound
accurate?

Without seeing the view template for your 'add_category' action, I'm
guessing that it contains the HTML markup for the list? E.g. it has
<select> elements and some kind of loop to generate the <option>s. Is
that correct?

The approach you would need to take I think would be one where instead
of making an AJAX request and the response being an HTML snippet which
you insert into a <div>, you need to make an AJAX request with the
response being JSON data, which you supply to a function which
constructs the <option>s for you and attaches them to the appropriate
<select> element. This way, your <select> elements could be defined
statically, and hence appear on the form from the first page load.

Does it sound like I'm on the right track? If so, I can provide you
with a small example on how to achieve this.

Cheers,
Michael

On Nov 24, 10:42 pm, Stephen <step...@ninjacodermonkey.co.uk> wrote:
> Hi Michael
>
> Thanks for the reply.
>
> What does your code look like at the moment?
>
> Please see:http://pastie.org/private/3ojfcqvo2g395rgab6cnbw
>
> I am using CakePHP 1.2
>
> Are you using any of the AJAX/JS helper methods provided by Cake?
>
> I am using the javascript helper and a modified ajax helper (for jquery).
>
> > Which JS engine are you using (jQuery, prototype, ...)?
>
>  jQuery
>
> > Are you firing a new AJAX request each time the value of a select list
> > changes?
>
>  Yes, all requests are initiated by $ajax->observeField() and complimented
> with a little jquery
>
> > Are you pre-loading all conceivable options once at the start and just
> > selecting the
> > appropriate subset of options when you change values?
>
> I am loading the appropriate subset of options when values are changed.
>
> Please see the attached images for extra clarification.
>
> *identifier.png* - this is the initial step, before any ajax requests are
> made.
>
> *vertical.png*- this is a blind which contains all 5 steps
>
> *roller.png  *- this is another blind which only contains 3 steps but uses
> the same form and system.
>
> *configuration.png*- This is a list of options which has been loaded due to
> your selection (into the #options div)
>
> if you see the vertical.png image, these fields will need to be all loaded
> at once when I select "Vertical Blind" from the identifier.
> You can see the way I structured the html in my pastie.
>
> Kind Regards
>  Stephen
>
>  vertical.png
> 12KViewDownload
>
>  roller.png
> 8KViewDownload
>
>  identifier.png
> 4KViewDownload
>
>  configuration.png
> 29KViewDownload

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: