Skip to content

Instantly share code, notes, and snippets.

@erikwett
Created October 22, 2016 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikwett/8ece706d825259fe0b9778034ecea213 to your computer and use it in GitHub Desktop.
Save erikwett/8ece706d825259fe0b9778034ecea213 to your computer and use it in GitHub Desktop.
function FieldList ( app ) {
/*....*/
app.getList( 'CurrentSelections', function ( reply ) {
me.selections = reply.qSelectionObject.qSelections;
//render since selections have changed
me.render();
//use qBackCount and qForwardCount to enable/disable back and forward buttons
$( "[data-qcmd='back']" ).toggleClass( 'disabled', reply.qSelectionObject.qBackCount < 1 );
$( "[data-qcmd='forward']" ).toggleClass( 'disabled', reply.qSelectionObject.qForwardCount < 1 );
} );
}
FieldList.prototype.render = function () {
var $fields = $( "#fields" ), str = "<ul class='list-group'>", added = {}, me = this;
if ( me.selections ) {
me.selections.forEach( function ( fld ) {
str += '<li class="list-group-item" data-value="' + fld.qField + '">' + fld.qField + '<span class="badge">' + fld.qSelectedCount + '/' + fld.qTotal + '</span></li>';
added[fld.qField] = true;
} );
}
/*..*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment