Skip to content

Instantly share code, notes, and snippets.

@Ridhwana
Last active May 30, 2017 10:00
Show Gist options
  • Save Ridhwana/4d4d919fa716f94a6eb90bf3a239c6a0 to your computer and use it in GitHub Desktop.
Save Ridhwana/4d4d919fa716f94a6eb90bf3a239c6a0 to your computer and use it in GitHub Desktop.
ember-js-tree
import Ember from 'ember';
export default Ember.Controller.extend({
searchTerm: '',
plugins: 'search',
searchOptions: {
'show_only_matches' : true
},
data: [
{
'text': 'Company 1',
'id': 'company-1',
'state': {
'opened': true
},
'a_attr': {
'people': 100
},
'children': [
{ 'text' : 'Headoffice',
'state': {
'opened': true
},
'children': [
{ 'text' : 'Branch 1' },
{ 'text' : 'Branch 2' },
]
}
]
},
{ 'text': 'Company 2',
'children': [
{'text': 'Headoffice' }
]
}
],
actions: {
handleJstreeEventDidOpen(e, data) {
alert('opened node');
},
closeAllNodes() {
this.get('jstreeActionReceiver').send('closeAll');
}
}
})
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
button, input {
margin: 30px
}
<div class="ui icon input input--sidebar-clone__search">
{{input type="text" placeholder="Search" class="prompt search-input form-control" value=searchTerm}}
<i class="search icon"></i>
</div>
{{ember-jstree
data = data
plugins = plugins
searchOptions = searchOptions
searchTerm = searchTerm
eventDidOpen = 'handleJstreeEventDidOpen'
actionReceiver = jstreeActionReceiver
}}
<button {{action 'closeAllNodes'}}>Close all nodes</button>
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1",
"ember-cli-jstree": "1.0.9"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment