Alright, figured it out.

Made some adjustments to the jquery_engine.php file.

Essentially, all that you need to do is find the request function, and
replace using "html" for content placement with whatever is stored in
$options['position']. Then, you can specify 'position' in your options
array for Js helper requests. If the option is not set, just fall back
to html. Here is the revised function - you'll notice I only made
minor additions and changes just below my **EDIT** comment. Everything
else was untouched.

/**
 * Create an $.ajax() call.
 *
 * If the 'update' key is set, success callback will be overridden.
 *
 * @param mixed $url
 * @param array $options See JsHelper::request() for options.
 * @return string The completed ajax call.
 * @access public
 * @see JsBaseEngineHelper::request() for options list.
 */
        function request($url, $options = array()) {
                $url = $this->url($url);
                $options = $this->_mapOptions('request', $options);
                if (isset($options['data']) && is_array($options['data'])) {
                        $options['data'] = 
$this->_toQuerystring($options['data']);
                }
                $options['url'] = $url;
                if (isset($options['update'])) {
                        $wrapCallbacks = isset($options['wrapCallbacks']) ?
$options['wrapCallbacks'] : true;
                        if ($wrapCallbacks) {

                                // **EDIT** Changed the following line to 
replace "html" with
$options['position'] so that I can personally specify where I want
this information. Need to default to "html" is no position is
specified though.
                                if(!isset($options['position'])){
                                        $options['position'] = "html";
                                }
                                $success = $this->jQueryObject . '("' . 
$options['update'] . '").'.
$options['position'].'(data);';
                        } else {
                                $success = sprintf(
                                        'function (data, textStatus) 
{%s("%s").html(data);}',
                                        $this->jQueryObject,
                                        $options['update']
                                );
                        }
                        $options['dataType'] = 'html';
                        $options['success'] = $success;
                        unset($options['update']);
                }
                $callbacks = array('success', 'error', 'beforeSend', 
'complete');
                if (isset($options['dataExpression'])) {
                        $callbacks[] = 'data';
                        unset($options['dataExpression']);
                }
                $options = $this->_prepareCallbacks('request', $options);
                $options = $this->_parseOptions($options, $callbacks);
                return $this->jQueryObject . '.ajax({' . $options .'});';
        }



On Jan 2, 9:26 pm, Eric Anderson <andersoneric...@gmail.com> wrote:
> Hi,
>
> Does anyone know how to position the insertion of a returned HTML from
> an AJAX request using the Js helper (JQuery) ? I know there is an
> 'update' option, however there are times when I need append, replace,
> etc instead of just updating a selected element.
>
> I took a look at the jquery_engine.php helper class and it doesn't
> seem to be built, but are there any other ways around this?
>
> Thanks,
>
> Eric

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to