I am looking for a way to add a button to a jQuery button-set at run-time with JavaScript.
if(response.success) {
var menuItem = document.createElement('a');
$(menuItem).attr('href', response.href);
$(menuItem).attr('category-id', response.id);
$(menuItem).text(title);
$("#menu-buttonset").append(menuItem);
}
I am adding the hyperlink to the div container of the button-set using JavaScript, and then re-calling buttonset() on the container.
$("#menu-buttonset").buttonset();
This however does not seem to rebuild the button-set as I expected.
I am not seeing any function in the jQuery API for this either.
Can anyone provide some insight?
Resolved:
Using refresh method as suggested, rebuilt the button-set.
$('#menu-buttonset').buttonset('refresh');