Ok! So now we've seen how to get our Ext JS party started and ask the user a question. Now let's see what we can do with their answers. Let's add to our dialog's function so that we can decide what to do in response to each of the button-clicks. A switch
statement can take care of deciding what to do in each case:
fn: function(btn) { switch(btn){ case 'yes': Ext.Msg.prompt('Milton', 'Where is it?'); break; case 'no': Ext.Msg.alert('Milton', 'I\'m going to burn the building down!'); break; case 'cancel': Ext.Msg.wait('Saving tables to disk...','File Copy'); break; } }
Note
Note how an apostrophe may be inserted into an apostrophe-delimited string by prefixing the character with a backslash. The same principle applies to inserting a "double" quote into a quote-delimited string.
Remember those built in dialog types I mentioned earlier? Well we just used some of them. They offer us pre-configured dialogs which let us accomplish some common tasks without spending time writing...