Sunday, May 19, 2013

Loading videos on the fly using video.js

Video.js doesn't have a lot of documentation when it comes to doing really cutom stuff. For example, loading videos using a partial postback and changing the subtitles. Fortunately I'm not the first one to run into this problem, and I found this link that shows how to do it. It works in Chrome and Firefox. IE 8/9 is different because it's Flash, so you have to check the browser type before executing the code.

Tuesday, May 14, 2013

Uncaught Error: ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node

This problem happens when you call applyBindings. The problem here is that your view is a jQuery object, not a DOM element. It can be fixed by appending [0], as described here.

Monday, May 13, 2013

Binding a partial view with knockout

If there's a part of your view which you don't want to bind right away, you can defer it very easily. The basic solution is to include this code:


ko.bindingHandlers.stopBinding = {
    init: function ()
    {
        return { controlsDescendantBindings: true };
    }
};

<section>
        <!-- ko stopBinding: true -->        
        <div></div>
        <!-- /ko -->
    </section>








You can also check out this detailed solution.