Can I destroy and then create a pop-up via snippet?

I have a pop-up that creates a case.  When I save the case record I’d like to give the user the option to create a related task.  If they opt-in to creating a task after creating the case I like the case pop-up to go away and then a new pop-up to appear with a task creation page.

Can someone drop me the javascript code to render a new pop-up?

Thanks!

Destroying a snippet is pretty easy with this line:

skuid.$(‘.ui-dialog-content’).dialog(‘close’);

Creating one is a lot more complex. Here is an example of a popup created using JS. You basically have to spell out the XML…

var params = arguments[0], $ = skuid.$,
list = params.list,
model = params.model,
$xml = skuid.utils.makeXMLDoc;

var popupXMLString =

'<popup width="50%" title="Error">'
    + '<components>'
        + '<pagetitle model="Opportunity">'
            + '<maintitle>' + 'An error occurred.' + '</maintitle>'
            + '<actions>'
                //+ '<action type="custom" snippet="FinishCaseEscalation" label="Complete Escalation" icon="ui-silk-accept"/>'
            + '</actions>'
        +'</pagetitle>'
        + '<basicfieldeditor model="Opportunity" mode="edit" showsavecancel="false">'
            + '<columns>'
                + '<column width="100%">'
                    + '<sections>'
                        + '<section title="Escalation Reason">'
                            + '<fields>'
                                + '<field id="CommentBody" required="true"/>'
                            + '</fields>'
                        + '</section>'
                    + '</sections>'
                + '</column>'
            + '</columns>'
        + '</basicfieldeditor>'
    + '</components>'
+ '</popup>';

var popupXML = $xml(popupXMLString);

var context = {};

var popup = skuid.utils.createPopupFromPopupXML(popupXML, context);

This looks good!  Thanks Moshe!

Thanks Moshe!

can i call one more snippet through this…

  //+ '<action type="custom" snippet="FinishCaseEscalation" label="Complete Escalation" icon="ui-silk-accept"/>' 

It looks like that line has a snippet call inside it " snippet=“FinishCaseEscalation” ". If you have a snippet with that name that would probably work. Or you might have to declare the snippet in the XML like:

var $ = skuid.$; ETC…