I'd say using your method is completely ok, but you should be aware of what you're doing there. For one thing, you're no longer adding Splunkjs Stack Views to your dashboard, i.e. you're not using a ChartView . Instead, you're using the Simple XML Wrapper ChartElement (the same that is used in dashboards once converted to html, see here and here).
I'm surprised you still see the "Edit -> Edit Panels" option. It should only be available as long as there are strictly views on your dashboards, without any wrappers. As soon as you use those, the function "Edit Panels" offers is no longer applicable (because your views are no longer views, they are now elements with their own settings which you can't edit from the web view) and thus should not be displayed any more. Therefore, I'd say it is expected behavior that your elements disappear when you enter the "Edit Panels" mode - they do not correspond to the settings you set there.
Maybe you can find another way to solve your initial problem (adding panels dynamically). Did you know about the depends attribute of panels? They allow you to hide views based on the presence of tokens, see here for docs (search for depends). Alternatively, you could look into the inner workings of the web framework at %SPLUNK_BASE/share/splunk/search_mrsparkle/exposed/js/splunkjs/mvc (and subfolders) and from there figure out how to add your elements to the model of the dashboard so that they are editable from "Edit Panels" - unfortunately, for specific help on what exactly you need to do there you'll have to ask someone really knowledgeable about it, e.g. on the IRC channel.
Good Luck!
... View more