Create a gist now

Instantly share code, notes, and snippets.

Accounts List JavaScript Component
<apex:component >
<script>
var accsListCtrl={
// renders the HTML to display the supplied accounts in bootstrap panels
renderAccs : function(accounts) {
var markup='';
$.each(accounts, function(idx, acc) {
markup+= ' <div class="row-fluid"> \n' +
' <div class="col-xs-12 fullwidth"> \n' +
' <div class="panel panel-primary"> \n' +
' <div class="panel-heading"> \n' +
' <h3 class="panel-title">' + acc.Name + '</h3> \n' +
' </div> \n' +
' <div class="panel-body"> \n' +
' <div class="top-buffer table-responsive"> ' +
' <label>Industry: </label>' + acc.Industry +
' </div> \n' +
' </div> \n' +
' <div class="panel-footer"> \n' +
' </div> \n' +
' </div> \n' +
' </div> \n' +
' </div> \n' +
' <div class="fluid-row"> \n' +
' <div class="col-xs-12 top-buffer"> \n ' +
' </div> \n' +
' </div> \n';
});
$('#accountsPanel').html(markup);
},
// get the latest accounts from the server
getAccounts : function() {
AccountsListController.GetAccounts(accsListCtrl.handleAccs);
},
handleAccs : function (result, event) {
if (event.status)
{
accsListCtrl.renderAccs(result);
}
else if (event.type === 'exception')
{
alert('Exception in Remote Action\n\nMessage: ' + event.message + '\n\nWhere: ' + event.where);
}
else
{
alert('Something else went wrong');
}
}
};
$(document).ready(function() {
accsListCtrl.getAccounts();
});
</script>
</apex:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment