Editable::attachAjaxUpdateEvent PHP Method

attachAjaxUpdateEvent() public static method

injects ajaxUpdate event into widget
public static attachAjaxUpdateEvent ( mixed $widget )
$widget mixed
    public static function attachAjaxUpdateEvent($widget)
    {
        $trigger = '$("#' . $widget->id . '").trigger("ajaxUpdate.editable");';
        //check if trigger already inserted by another column
        if (strpos($widget->afterAjaxUpdate, $trigger) !== false) {
            return;
        }
        //inserting trigger
        if (strlen($widget->afterAjaxUpdate)) {
            $orig = $widget->afterAjaxUpdate;
            if (strpos($orig, 'js:') === 0) {
                $orig = substr($orig, 3);
            }
            $orig = "\n({$orig}).apply(this, arguments);";
        } else {
            $orig = '';
        }
        $widget->afterAjaxUpdate = "js: function(id, data) {\n            {$trigger} {$orig}\n        }";
        $widget->registerClientScript();
    }

Usage Example

Beispiel #1
0
 public function init()
 {
     if (!$this->name) {
         throw new CException('You should provide name for EditableColumn');
     }
     parent::init();
     //need to attach ajaxUpdate handler to refresh editables on pagination and sort
     Editable::attachAjaxUpdateEvent($this->grid);
 }