Widgets > wijlist > wijlist Tutorial > wijlist Step 2 of 3: Initializing the Widget |
In the previous step, you created the list element. In this step, you will add the jQuery script that creates the array and initializes the widget.
After the closing <div>
tag, add the following script:
<script id="scriptInit" type="text/javascript">
$(document).ready(function () {
var testArray = [{
label: 'c++',
value: 'c++'
}, {
label: 'java',
value: 'java'
}, {
label: 'php',
value: 'php'
},
{
label: 'javascript',
value: 'javascript'
}];
var list = $("#list");
var input = $('#testinput');
//initialize list
list.wijlist({});
list.wijlist('setItems', testArray);
list.wijlist('renderList');
list.wijlist('refreshSuperPanel');
});
</script>