1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    33
    Answers
    2
    Vote Rating
    0
    alane is on a distinguished road

      0  

    Default Answered: fireEvent with Ext.Msg.prompt

    Answered: fireEvent with Ext.Msg.prompt


    I'm currently working on unit tests using Jasmine, and I've had a fairly easy time of getting actions to occur using Ext JS's fireEvent method to put my app through it's paces during the tests, but I'm having difficulty getting the fireEvent to work in a window created by Ext.Msg.prompt.

    Basically, I have an event that fires a Ext.Msg.confirm window when a selection is changed.

    Code:
    Ext.Msg.confirm('Change Status','Do you want to  change this status?',  function(btn){<br>              if(btn=='no'||  btn=='cancel'){<br>                    combobox.setValue(model.get('status'));<br>               }<br>              else  {<br>                    this.saveStatustoDB(model,  combobox);<br>               }          <br>});
    I believe that to carry on the change in selection and proceed to testing, I have to programmatically fire the click event on the 'yes' button.

    I tried using
    Code:
    var promptwin =  <br>Ext.ComponentQuery.query('window')[0]
    <br>to find the window, and therefore the button, but something is going wrong - neither
    Code:
    promptwin.defaultFocus.fireEvent('click');
    nor
    Code:
    promptwin.close();
    works.
    Code:
    Ext.Msg.hide();
    will hide the window, but not pass the confim's function.

    Is there a different way I can confirm this window programattically, or am I missing something with how to get a 'handle' on the window to fire the click event?

    I've been able to use fireEvent('click') on buttons within the app, so I know that's effective on it's own. I appreciate any help on this matter.

  2. Actually, after more experimentation, I found my own answer with btnCallback.

    Code:
    var promptwin = Ext.ComponentQuery.query('window')[0];
              promptwin.btnCallback(promptwin.query('button')[1]);

  3. #2
    Sencha User
    Join Date
    Aug 2012
    Posts
    33
    Answers
    2
    Vote Rating
    0
    alane is on a distinguished road

      0  

    Default


    Actually, after more experimentation, I found my own answer with btnCallback.

    Code:
    var promptwin = Ext.ComponentQuery.query('window')[0];
              promptwin.btnCallback(promptwin.query('button')[1]);