I'd like to insert a button and a mdl-menu as a tooltip in the html page.
Here is a sample Javascript code:
$(function(){
$("#dynamic").html('<button id="share-post-2" class="mdl-button mdl-button--icon mdl-button--colored">\
<i class="material-icons">share</i></button>\
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu" for="share-post-2">\
<li class="mdl-menu__item">Facebook</li>\
<li class="mdl-menu__item">Twitter</li>\
<li class="mdl-menu__item">Pinterest</li>\
</ul>');
});
And the html is simple:
<div id='dynamic'></div>
The problem is that the menu will not show up on button click as expected. However, if I hard code it in html, it works.
The question is how to make the mdl-menu pop up on button click. Thanks!
Here is a jsFiddle I made for test.