Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support override of JsTree options from widget #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Support override of JsTree options from widget #3

wants to merge 2 commits into from

Conversation

lennartvdd
Copy link

For more flexibility I thought it would be nice to be able to set any JsTree option directly when calling the widget in a view, so i've added an $options attribute to the JsTreeWidget class.
Any options set there will be merged to the default options defined in js_plugins/jstree.behavior.js using JQuery's $.extend(true, {}, {});, meaning if you define JsTreeWidget::$options, the defaults will not be lost, but can only be overriden or extended.

Example:

<?php
$this->widget('application.widgets.JsTreeWidget', array(
    #...
    'options' => array(
        'html_data'=>array(
            'ajax' => array(
                'url' => $this->createUrl('fetchTree', array('id' => $_GET['id'])),
            ),
        ),
        'types' => array(
            'max_children' => 1,
        ),
    ),
    #...
));
?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant