X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=e01675ff9159fa4f7b1252d0dad510ac40c5f756;hb=c596828a3f46ba519690bbaee9e82c5b433a5e32;hp=1ea183522d9084df1216cbf0a252209b96c02f55;hpb=6fca436aa42f947b752e583ecf1fe201769782a2;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 1ea1835..e01675f 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -1,3 +1,5 @@ +(function($) { // jQuery wrapper + // Functions follow for promoting the regular widget object into // widgets of specific types. These could be moved into their own // source files. @@ -86,6 +88,25 @@ mkws.registerWidgetType('Pager', function() { }); }); +mkws.registerWidgetType('Details', function() { + var that = this; + var recid = that.node.attr("data-mkws-recid"); + if (this.team.gotRecords()) { + that.team.fetchDetails(recid); + } else { + this.team.queue("firstrecords").subscribe(function() { + that.team.fetchDetails(recid); + }); + } + this.team.queue("record").subscribe(function(data) { + console.log(data); + if ($.inArray(recid, data.recid) > -1) { + var template = that.team.loadTemplate(that.config.template || "Record"); + that.node.html(template(data)); + } + }); + that.autosearch(); +}); mkws.registerWidgetType('Records', function() { var that = this; @@ -105,7 +126,6 @@ mkws.registerWidgetType('Records', function() { if (hit.recid == team.currentRecordId()) { if (team.currentRecordData()) { hit.renderedDetails = team.renderDetails(team.currentRecordData()); - console.log(hit.renderedDetails); } } } @@ -367,3 +387,4 @@ mkws.registerWidgetType('MOTDContainer', function() {}); mkws.registerWidgetType('Button', function() {}); +})(mkws.$); // jQuery wrapper