I have the following code which creates an MDL Card on the fly
var resultsHolder = $('#resultsHolder');
var gridHolder = $('<div>',{ 'class' : 'mdl-grid' });
var card = $('<div>',{ 'class' : 'mdl-card.mdl-shadow--2dp data-display' });
var title = $('<div>',{'class' : 'mdl-card__title'});
var h4 = $('<h4>');
var supportingText = $('<div>',{'class' : 'mdl-card__supporting-text'});
var supportingPara = $('<div>',{'class' : 'projectDesc'});
h4.append($('#projectName').val());
title.append(h4);
supportingPara.append($('#projectDesc').val());
supportingText.append(supportingPara);
card.css('width','100%');
card.append(title);
card.append(supportingText);
gridHolder.append(card);
resultsHolder.prepend(gridHolder);
componentHandler.upgradeElement(resultsHolder);
While the contents of the new card appears. None of the border or background appears.
I have seen the following link
How can I update/refresh Google MDL elements that I add to my page dynamically?
but using any of the following;
- componentHandler.upgradeDom();
- componentHandler.upgradeElement();
pass the class of the card holder - $('#resultsHolder')
None seem to make a difference.
So how can I make my full card appear.