Span not updated by MVVM

3 posts, 0 answers
  1. Andreas
    Andreas avatar
    3 posts
    Member since:
    Feb 2016

    Posted 24 Feb 2016 Link to this post



    I've been trying out the MVVM system for an upcoming project, and I seem to have a problem with understanding the basics. All of the examples/samples I've tried from the Kendo webpage have worked as intended, but my own test refuses to function.

    Basically I have a span with a text value, which is changed by a button click. Simple. The problem is that, even though the ViewModel is updated (according to console print-outs), the text being displayed on the website does not.

    I hope someone could have a look at this and tell me what I'm doing wrong - really is a very simple example.


    <!DOCTYPE html>
        <meta charset="utf-8" />
        <div id="app">
            <div id="replaceMe"></div>
            <button id="swapButton">Swap Text</button>
        <script type="text/x-kendo-template" id="template">
                <span data-bind="text:displayMe">Not bound</span>
        <script type="text/javascript">
            var viewModel = kendo.observable({
                displayMe: "Foo",
                swapText: function () {
                    if (this.displayMe == "Foo") {
                        this.displayMe = "Bar";
                    } else {
                        this.displayMe = "Foo";
                click: function (e) {
                    console.log("Swapped Text: " + viewModel.displayMe);
            var template = kendo.template($("#template").html(), { useWithBlock: false });
            var templateAsHtml = template({});
            kendo.bind($("#replaceMe"), viewModel);





  2. Petyo
    Petyo avatar
    2444 posts

    Posted 25 Feb 2016 Link to this post


    you need to use the set method when changing values.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Andreas
    Andreas avatar
    3 posts
    Member since:
    Feb 2016

    Posted 25 Feb 2016 Link to this post

    Snap. Knew it was something simple.

    Thank you for the help Petyo - works like a charm now.

Back to Top