0

Html:

<p>Order</p>
<div>
<ul data-role="listview" id="myorder"></ul>
</div>

JS:

itemName = ["beer1", "beer2", "beer3", "beer4"];
itemQty = [0, 2, 0, 4];

for ( var i=0, len=itemName.length; i<len; ++i) { 
    if (itemQty[i] > 0) {
        var listItem = document.createElement("li");
        listItem.innerHTML = itemName[i] + "    Qty:" + itemQty[i];
        $('#myorder').append(listItem);
        $('#myorder').listview('refresh');
    }
}

I know its staring me right in the face but why is this only showing my first instance of Qty > 0?

http://jsfiddle.net/Sptx7/

1 Answer 1

1

You're getting an error here:

$('#myorder').listview('refresh');

since listview is undefined, so the code terminates.


Here's your fiddle with that line commented out: http://jsfiddle.net/Sptx7/2/

As you can see, it renders both list items.

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.