3

HTML:

<div id="demo">
    <h1>{{title | uppercase}}</h1>
    <ul>
        <li v-repeat="todos" v-on="click: done = !done" class="{{done ? 'done' : ''}}">
            {{content}}
        </li>
    </ul>
</div>

JS:

var demo = new Vue({
    el: '#demo',
    data: {
        title: 'todos',
        todos: [] //testing with data use: [{done:false,content:'testing'}]
    }
});

Or: http://jsfiddle.net/ksumarine/yMv7y/301/

I would like to display "No todos at this time" or something similar if the data comes back as empty. I can't figure out how to do this.

Also, when I have something similar to this in my app, I see the mustache bindings on the page before Vue replaces it with the data. Any thoughts on how to hide the bindings from the user?

Thanks for the help!

1 Answer 1

12

You can use v-if="!todos.length" to make the message display only when the todos array is empty.

For the flash of bindings, use v-cloak together with a CSS rule to hide it until the compilation finishes.

Combined example: http://jsfiddle.net/yMv7y/304/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.