Knockoutjs event binding not working

24 views
Skip to first unread message

Tridip Bhattacharjee

unread,
May 17, 2015, 1:50:42 PM5/17/15
to knock...@googlegroups.com

i was reading way out to attach mouse over and out with Knockoutjs and then i got a page http://knockoutjs.com/documentation/event-binding.html

from here i got a code for attaching mouse over and out with event binding in Knockoutjs. i try to paste the code in jsfiddle and try to run but nothing happen when i run the code. here is the jsfiddle link https://jsfiddle.net/tridip/6u4veobj/

here is the mouse over and out code

<div>
    <div data-bind="event: { mouseover: enableDetails, mouseout: disableDetails }">
        Mouse over me
    </div>
    <div data-bind="visible: detailsEnabled">
        Details
    </div>
</div>

var viewModel = {
        detailsEnabled: ko.observable(false),
        enableDetails: function() {
            alert('over');
            this.detailsEnabled(true);
        },
        disableDetails: function() {
            alert('out');
            this.detailsEnabled(false);
        }
    };
    ko.applyBindings(viewModel);

just tell me why the mouseover and mouseout is not working ??

Gunnar Liljas

unread,
May 17, 2015, 5:24:50 PM5/17/15
to knock...@googlegroups.com
Have a look at your error console.

Add the KO reference using https (or //) or go to http://jsfiddle.net/tridip/6u4veobj/



--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages