0
我有一個使用XML數據源的應用程序。MeteorJS:在返回API結果時加載微調器
用戶可以從下拉菜單中選擇一個類別,然後執行API調用來拉回XML數據源進行處理。 A)如何使用數據更新我的前端集合? B)如何在收藏更新時展示微調?
的JavaScript
var getJobsByIndustry = function(onet) {
if(typeof(onet) === "undefined")
alert("Must include an Onet code");
var url = "onet=" + onet;
Meteor.call('retrieveJobs', url, function(error, results){
console.log(results)
});
};
Template.selector.events({
'click div.select-block ul.dropdown-menu li': function(e) {
var selectedIndex = $(e.currentTarget).attr("rel");
var val = $('select#industryPicker option:eq(' + selectedIndex + ')').attr('value');
var oldVal = Session.get('currentIndustryOnet');
if(val != oldVal) {
Session.set('currentIndustryOnet', val);
Session.set('jobsLoaded', false);
getJobsByIndustry(val);
}
}
});
模板:
<template name="list">
<div class="col-md-12">
{{#if jobsLoaded}}
<ul class="list-group" id="jobs">
{{#each jobs}}
<li>
<span class="pull-right">{{address}}</span>
<span id="jobTitle">{{title}}</span>
<span id="company">{{company}}</span>
<span id="date"><em>{{dateacquired}}</em></span>
</li>
{{/each}}
</ul>
{{else}}
{{> spinner}}
{{/if}}
</div>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-2">
<select id="perPage" class="selectpicker select-block" _val="{{selected_opt}}">
<option value="10">10 Per Page</option>
<option value="25">25 Per Page</option>
<option value="50">50 Per Page</option>
<option value="100">100 Per Page</option>
</select>
</div>
<div class="col-md-10">
{{{pagination}}}
</div>
</div>
</div>
</div>
</template>
非常感謝您的幫助! – dennismonsewicz