Development

#252 (json prototype not taken into account by symfony call_backs)

You must first sign up to be able to contribute.

Ticket #252 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

json prototype not taken into account by symfony call_backs

Reported by: benoitm Assigned to:
Priority: trivial Milestone: 0.6.1
Component: Version: 0.6.0
Keywords: Cc:
Qualification:

Description

When using AJAX prototype function symfony generate callback function with prototype:

function(request):

but the prototype 1.4 is said to parse the request header for 'X-JSON' and automatically evaluate it and return it has a second parameter to the callback function. Therefore we should now take this into account by modifying the JavascripHelper?.php to:

function _build_callbacks($options)
  {
    $callbacks = array();
    foreach (get_callbacks() as $callback)
    {
      if (isset($options[$callback]))
      {
        $name = 'on'.ucfirst($callback);
        $code = $options[$callback];
        $callbacks[$name] = 'function(request, json){'.$code.'}';
      }
    }

just adding the ",json" does the trick. then in you view template output:

<?php //$sf_context->getResponse()->setHttpHeader("X-JSON", '('.$value')'); ?>

makes it works with json prototype implementation.

Thanks.

Change History

02/26/06 18:09:18 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

fixed in r885.

02/26/06 18:28:17 changed by anonymous

Illustration of this can be show in wiki page : AjaxAndJSON