X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=51068396948d2f3a6b898b6753c87ab06a6b4edf;hb=6c46a50ba2658fb08aeb3cf12fa1b6558ca28057;hp=3761752ad4003164d347fd145b64275306acbc79;hpb=2dbe2fe01a6eb8740d4c861149e84c1329793e56;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 3761752..5106839 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -116,28 +116,26 @@ mkws.registerWidgetType('Records', function() { var team = this.team; this.team.queue("records").subscribe(function(data) { - var html = []; for (var i = 0; i < data.hits.length; i++) { var hit = data.hits[i]; that.team.queue("record").publish(hit); - var divId = team.recordElementId(hit.recid[0]); - html.push('
', renderSummary(hit), '
'); + hit.detailLinkId = team.recordElementId(hit.recid[0]); + hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" + hit.containerClass = "mkwsSummary mkwsTeam_" + team.name(); + hit.containerClass += " " + hit.detailLinkId; // ### At some point, we may be able to move the // m_currentRecordId and m_currentRecordData members // from the team object into this widget. if (hit.recid == team.currentRecordId()) { - if (team.currentRecordData()) - html.push(team.renderDetails(team.currentRecordData())); + if (team.currentRecordData()) { + hit.renderedDetails = team.renderDetails(team.currentRecordData()); + console.log(hit.renderedDetails); + } } } - that.node.html(html.join('')); - - function renderSummary(hit) { - var template = team.loadTemplate(that.config.template || "Summary"); - hit._id = team.recordElementId(hit.recid[0]); - hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" - return template(hit); - } + var template = team.loadTemplate(that.config.template || "Records"); + var targs = $.extend({}, {"hits": data.hits}, that.config.template_vars); + that.node.html(template(targs)); }); that.autosearch();