我克隆了Dashing List小部件并对其进行了编辑,因此它将包含三个单独的列表,例如in this image。与窗口小部件关联的作业向REST API搜索端点发出GET请求,然后创建前五个结果的哈希。除了班级名称之外,coffeescript未经修改。
窗口小部件显示每个列表的正确项目数,但不显示实际数据(对象名称和视图数)。我正在调试模式下运行仪表板,it is receiving the correct data,但是这些数据没有填充在小部件本身中。
我对Dashing(以及它使用的许多框架)都是新手,这是我遇到的第一个绊脚石。出了什么问题?
作业:
SCHEDULER.every '1h' do
ldata = get_data(lots)
hdata = get_data(houses)
sdata = get_data(stores)
send_event('most-pop-items', {litems: ldata[:mostPop], hitems: hdata[:mostPop], \
sitems: sdata[:mostPop], titems: ldata[:mostPop]})
end
def get_data(org)
@data = { }
response = org.search({:orgid => @data[:id], :sortField => 'numViews', :sortOrder => 'desc'})
@data[:numItems] = response['total']
@data[:mostPop] = {}
for counter in 0..4
@data[:mostPop][counter] = {:label => response['results'][counter]['title'], \
:value => response['results'][counter]['numViews']}
end
return @data
end
Widget html:
<h1 class="title" data-bind="title"></h1>
<h3 class="htitle" data-bind="htitle"></h3>
<ol>
<li data-foreach-item="hitems">
<span class="label" data-bind="hitem.label"></span>
<span class="value" data-bind="hitem.value"></span>
</li>
</ol>
<ul class="list-nostyle">
<li data-foreach-item="hitems">
<span class="label" data-bind="hitem.label"></span>
<span class="value" data-bind="hitem.value"></span>
</li>
</ul>
<br>
<h3 class="stitle" data-bind="stitle"></h3>
<ol>
<li data-foreach-item="sitems">
<span class="label" data-bind="sitem.label"></span>
<span class="value" data-bind="sitem.value"></span>
</li>
</ol>
<ul class="list-nostyle">
<li data-foreach-item="sitems">
<span class="label" data-bind="sitem.label"></span>
<span class="value" data-bind="sitem.value"></span>
</li>
</ul>
<br>
<h3 class="ltitle" data-bind="ltitle"></h3>
<ol>
<li data-foreach-item="litems">
<span class="label" data-bind="litem.label"></span>
<span class="value" data-bind="litem.value"></span>
</li>
</ol>
<ul class="list-nostyle">
<li data-foreach-item="litems">
<span class="label" data-bind="litem.label"></span>
<span class="value" data-bind="litem.value"></span>
</li>
</ul>
<br>
<h3 class="ttitle" data-bind="ttitle"></h3>
<ol>
<li data-foreach-item="titems">
<span class="label" data-bind="titem.label"></span>
<span class="value" data-bind="titem.value"></span>
</li>
</ol>
<ul class="list-nostyle">
<li data-foreach-item="titems">
<span class="label" data-bind="titem.label"></span>
<span class="value" data-bind="titem.value"></span>
</li>
</ul>
<p class="more-info" data-bind="moreinfo"></p>
<p class="updated-at" data-bind="updatedAtMessage"></p>
答案 0 :(得分:2)
尝试更改您已恢复原始数据绑定的数据绑定,仅item.label
和item.value
这些不必像您为匹配data-for-each
项目那样重命名