Hi,
if it is some more code, it's just not readable very well without
proper formatting and highlighting, more people will enjoy your code
if you use cakebin. :-)
Did you also try to put the code for the second observer in the
complete-function of the first ajax observer? What you can also do
about ajax populated js-code to be executed, is to put in a javascript-
header in the answer, like:
<?php header('Content-type: application/x-javascript'); ?>
On 26 Jun., 19:36, Mike <[EMAIL PROTECTED]> wrote:
> Hello!
>
> Thanks for the reply!
>
> Late(r) last night, I browsed through the prototypejs.org site, and
> found:
>
> http://prototypejs.org/learn/introduction-to-ajax
> "If your HTML comes with inline scripts, they will be stripped by
> default. You'll have to pass true as the evalScripts option in order
> to see your scripts being executed."
>
> So I figured that I'd get up early today, and make sure that
> evalScripts is there, and hopefully fix everything. However, when I
> checked the output of observeField, I'm seeing a script element that
> contains:
>
> <![CDATA[
> new Form.Element.Observer('SELECTTERM', 1,
> function(element, value) {
> new Ajax.Updater(document.createElement('div'), '/CakePHP/ST/
> main/updateCourse', {asynchronous:true,
> evalScripts:true,
>
> parameters:Form.Element.serialize('SELECTTERM'), requestHeaders:['X-
> Update', 'dynamic1 dynamic2']})})
> ]]>
>
> So it looks like evalScripts is true for the observer that's watching
> the first select box. For the heck of it, I tried hacking cake/.../
> ajax.php to throw in evalJS:true,evalJSON:true, but those didn't
> really help, either.
>
> What is bin.cakephp.org? Is that better than including the source in
> the above posting?
>
> Thanks!
> --Mike
>
> On Jun 26, 2:43 am, schneimi <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I am not sure, but it could be a problem
> > likehttp://groups.google.com/group/cake-php/browse_thread/thread/d7c97c5f...
>
> > Better usehttp://bin.cakephp.org/topost your code.
>
> > Hope this helps,
>
> > Michael
>
> > On 26 Jun., 09:07, Mike <[EMAIL PROTECTED]> wrote:
>
> > > Hello!
>
> > > I've looked at the docs, at the API, and a little bit at the source,
> > > as well as Googling around for this, but I can't seem to find any
> > > answers, and I'm kinda stuck :)
>
> > > I'm trying to use the Cake 1.2.0.6311 (beta) distribution, and I've
> > > tried it using both FireFox 3 and IE 7.0.5730.13
>
> > > I'm trying to use Cake's built-in AjaxHelper, to create form with a
> > > 'cascading select' - the user is presented with a drop-down list (a
> > > select), and once they've made a section, then the observeField that
> > > was watching that select uses
> > > the built-in AJAX support to update an $ajax->div, in order to add the
> > > second drop-down (as well as a second observeField, for that drop-
> > > down)
>
> > > The problem I'm running into is that when I try to update the div, it
> > > doesn't actually print the script (as far as I can tell). When I use
> > > FireBug, I can verify that the non-javascript output is present on
> > > either side of the script in the div, but the actual output of
> > > $ajax->observeField is not there. (This is annotated in the code below
> > > with
>
> > > "NOTE NOTE NOTE")
>
> > > The odd thing is that when I write the first select into the form, and
> > > the first observeField (i.e., when the page is first generated), that
> > > all works fine - it's only when I try to put the observeField output
> > > into the div that I'm updating that problems arise.
>
> > > If anyone has any experience with this, and wouldn't mind helping me
> > > out, I'd greatly appreciate it! :)
>
> > > I'll include the code here, in case it's helpful:
>
> > > (Yeah, it's awful stuff - I've been stuck on the 'getting it to work'
> > > phase, and so haven't been able to go back & polish it up)
> > > ****************** View Code Snippet (student.ctp) **************
>
> > > <td colspan="4"><fieldset><legend>Enroll In A
> > > Course</legend>
> > > <?php
> > > echo $ajax->form( array('action' =>
> > > '/main/enrollInCourse'),
> > >
> > > 'post',
> > > array('update' =>
> > > 'dynamic1', 'id'
> > > =>'courseSelectionForm' ));
>
> > > echo 'First, choose a term: ';
>
> > > echo $this->renderElement('selectTerm',
> > > array(
> > > 'termList' => $terms,
> > >
> > > 'formHelper' => $form) );
> > > // This element I made - it generates
> > > something like:
> > > // <select name="data[SELECTTERM]"
> > > id="SELECTTERM">
> > > // <option value="-1"
> > > selected="selected">Select A Term</option>
> > > // <option value="2">2002 Winter</option>
> > > // <option value="1">2001 Fall</option>
> > > // </select>
>
> > > echo $ajax->observeField('SELECTTERM',
> > > array( 'frequency'=>'1',
> > >
> > >
> > > 'url'=>'/main/updateCourse',
> > >
> > >
> > > 'update'=>array('dynamic1', 'dynamic2'),
> > >
> > > ) );
>
> > > echo $ajax->div('dynamic1');
>
> > > echo "<pre>data2: ";
> > > print_r($data2);
> > > echo '<br/>showC: ' . $showCourses;
> > > echo "</pre>";
>
> > > $WTF = $ajax->observeField('SELECTCOURSE',
> > > array( 'frequency'=>'1',
> > >
> > > 'url'=>'/main/updateCourse',
> > >
> > > 'update'=>array('dynamic1', 'dynamic2'),
> > >
> > > ) );
>
> > > if($showCourses)
> > > {
> > > echo 'Next, choose a course: ';
> > > echo
> > > $this->renderElement('selectCourse',
> > > array(
> > > 'courseList' => $courses,
> > >
> > > 'formHelper' => $form) );
> > > // This element I made - it
> > > generates something similar to
> > > selectTerm
>
> > > // NOTE NOTE
> > > NOTE::::::::::::::::::::::::::::::::::::::::::::::::::::::
> > > // Here's where it gets weird:
> > > $cln = new Sanitize();
> > > echo $cln->html($WTF); // I can
> > > see this output fine
>
> > > echo "WTF????" . $WTF . "SFSDFSD";
> > > // I can see WTF????, and I can
> > > see SFSDFSD, but according to
> > > FireBug,
> > > // there's no <script> element
> > > between them!
>
> > > }
>
> > > echo $ajax->divEnd('dynamic1');
>
> > > echo $ajax->div('dynamic2');
>
> > > echo 'Finally, click here to enroll! ' .
> > > $goodToGo . 'fff<br/>';
> > > if($goodToGo)
> > > {
> > > echo $form->end( 'Submit');
> > > }
> > > else
> > > {
> > > echo 'ending form...';
> > > echo $form->end( );
> > > }
> > > echo $ajax->divEnd('dynamic2');
> > > ?>
> > > <hr/>
>
> > > </fieldset></td>
>
> > > ****************** Controller Code Snippet (main_controller.php)
> > > **************
>
> > > function updateCourse()
> > > {
> > > // $this->layout='defaultajax';
>
> > > $terms = $this->Term->find('all', array(
> > > //'conditions' => array('name' => 'Thomas
> > > Anderson'),
> > > //'fields' => array('name', 'email'),
> > >
>
> ...
>
> Erfahren Sie mehr »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---