问题
I’m writing a Dashcode app that contains a list. I’d like to populate this list with my data, but when I define the function
function populate_list()
{
var list = document.getElementById("list");
list.setDataArray(test_data);
list.reloadData();
}
I get an error; I think the reason is that list
in this context is a normal HTML ul
element and not an instance of the fancy DC.List
class that Apple has defined. How can I access my list in such a way that I can use its methods and access its properties?
回答1:
In dashcode under library/code there is an example titled 'List Data Source'. You will also need to alter the list object datatype to dynamic and then select your datasource from the dropdown list.
回答2:
It turns out that I wanted to do
var list = document.getElementById("list").object;
来源:https://stackoverflow.com/questions/6636834/editing-the-data-in-a-list-in-a-dashcode-app