superartsy superartsy - 6 months ago 24
jQuery Question

collapsible menu using knockout and jquery

I am trying to build a simple collapsible menu using knockout and jquery. But for some reason jquery is not being activated.

the script is located here jsfiddle

<ul id="usernav" data-bind="template: { name: 'seasonTemplate', foreach: seasons, as: 'season' }"></ul>

<script type="text/html" id="seasonTemplate">
<strong data-bind="text: name"></strong>
<ul data-bind="template: { name: 'monthTemplate', foreach: months, as: 'month' }"></ul>

<script type="text/html" id="monthTemplate">
<span data-bind="text: month"></span>
is in
<span data-bind="text:"></span>

the script is

var viewModel = {
seasons: ko.observableArray([
{ name: 'Spring',
months:[ 'March' , 'April', 'May' ]},
{ name: 'Summer', months: [ 'June', 'July', 'August' ] },
{ name: 'Autumn', months: [ 'September', 'October', 'November' ] },
{ name: 'Winter', months: [ 'December', 'January', 'February' ] }


$('li').click(function(e) {

So yes I may have forgotten to include the jquery library in the original jsfiddle post while copy pasting, but that is not my issue. I created a separate question regarding my issue here


Help us help you first by updating your jsFiddle.

If this is NOT your answer, i'll delete it myself, but, fixing jquery library made your code work, so this 'might' be an answer (sic).

screen capture of jsfiddle libraries

On jsFiddle, update your javascript libraries and ADD jquery.

Your resulting jsFiddle