When you click the 'New Panel' button, a new panel will be loaded in place of the old. I cannot figure out the code to do this. Below is my attempt to do this with js/jquery:
precode
var Panel = function() {
var that = {},
_panel = $('#mypanel');
Code: Select all
var page = _panel.parents("[data-role=page]");
page.append(_panel);
if (_panel == $('#mypanel')) {
_panel.on("panelbeforeopen", function(event, ui) {
$("#close_panel").die().live("click", function() {
that.close();
});
$("#new_panel").on("click", function() {
that.change();
});
});
} else if (_panel == $('#mypanel2'))
{
_panel.on("panelbeforeopen", function(event, ui) {
$("#close_panel").die().live("click", function() {
that.close();
});
});
}
that.open = function() {
_panel.panel('open');
};
that.close = function() {
_panel.panel("close");
};
that.change = function() {
_panel.empty().remove();
_panel = $('#mypanel2');
page = _panel.parents("[data-role=page]");
page.append(_panel);
_panel.panel('open');
};
return that;
};
/code/pre