yii-dream-team / yii2-jstree

Yii2 jsTree component
http://yiidreamteam.com/yii2/jstree
30 stars 7 forks source link

ajax lazy loaging #6

Open marcinmisiak opened 7 years ago

marcinmisiak commented 7 years ago

if jstree doc we have: // AJAX $('#tree').jstree({ 'core' : { 'data' : { 'url' : '/get/children/', 'data' : function (node) { return { 'id' : node.id }; } } });

You can not configure widget like this: [ 'data' => [ 'url' => Utr:to['tree/ajax']), data =>'function (node) { return { 'id' : node.id }; }' ] because Json::encode always add quotas ("). JavaScript send to browser:

$.jstree( ... "data": { "url": "http://www", "data":"function (node) { return { 'id' : node.id }; }" } but we need: $.jstree( ... "data": { "url": "http://www", "data": function (node) { return { 'id' : node.id }; } }

lvbaocheng commented 6 years ago

The same problem: I wrote this, and it didn't show up: 'core' => [ 'data' => [ 'url' =>$url, ] ], @russianlagman Can you help me?Thank you!

tezrik commented 4 years ago
$data = ['text' => 'test']
$response = Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_JSON;
$response->data = $data;
return $response;