Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorgizmo
     

    Hello everybody. I'm trying to create a sortable list with Akelos scriptaculous helper, but i'm encountering errors: $scriptaculous_helper->sortable_element('items_id', array('url' => array('action' => 'order'))) generate a "Call to undefined method ScriptaculousHelper::_optionsForAjax()" error. This is probably because ScriptaculousHelper class make a static call (line 110) to PrototypeHelper::remote_function, but remote_function calls $this->_optionsForAjax, using $this in a static context. Is this a bug or am i missing something?

    •  
      CommentAuthorfrancois
     
    Hi Gizmo,

    May be you can call the method using in your Helper the yet instantiated object ScriptaculousHelper $this->_controller->scriptaculous_helper->sortable_element()
    •  
      CommentAuthorfrancois
     
    Here the fix.

    Need to change the function sortable_element in the scriptaculous_helper.

    function sortable_element($element_id, $options = array())
    {
    $options['with'] = !empty($options['with']) ? $options['with'] : "Sortable.serialize('{$element_id}')";
    // $options['onUpdate'] = !empty($options['onUpdate']) ? $options['onUpdate'] : "function(){".PrototypeHelper::remote_function($options)."}";
    $options['onUpdate'] = !empty($options['onUpdate']) ? $options['onUpdate'] : "function(){".$this->_controller->prototype_helper->remote_function($options)."}";

    foreach ($options as $key=>$option) {

    /**
    * @todo: fix this code when implemented PrototypeHelper
    *
    * if (in_array(PrototypeHelper::AJAX_OPTIONS[$option])) {
    * unset($options[$option]);
    * }
    */
    if (in_array($key,$this->_controller->prototype_helper->getAjaxOptions())) {
    unset($options[$key]);
    }


    }

    $more_ajax_options = array('tag', 'overlap', 'constraint', 'handles');

    foreach ($more_ajax_options as $key=>$option) {
    if (in_array($option,$options)) {
    $options[$option] = "'{$options[$option]}'";
    }
    }

    if (in_array('containment',$options)){
    $options['containment'] = JavascriptHelper::_array_or_string_for_javascript($options['containment']);
    }

    if (in_array('only',$options)){
    $options['only'] = JavascriptHelper::_array_or_string_for_javascript($options['only']);
    }

    return JavascriptHelper::javascript_tag("Sortable.create('{$element_id}', ".JavascriptHelper::_options_for_javascript($options).")");
    }