1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    122
    Vote Rating
    0
    moraes is on a distinguished road

      0  

    Default BasicDialog: how to submit a form without AJAX.

    BasicDialog: how to submit a form without AJAX.


    The short question is...
    I have a BasicDialog which element is a form. I want to trigger submit() in the form without using AJAX, and I have no clue which element to use to call submit().

    The long question is...
    I have some auto-created dialogs which element is a form:

    autoCreate: {tag:'form', method:'post', action:'...', name: '...'}

    And it is all ok to handle AJAX submissions et al, but guess what, now I can't find a way to submit a form using these dialogs without being async. I've added a 'preventAsync' property to my dialogs to submit the form in the old way and avoid starting the async process:

    Code:
    this.okBtn = this.addButton('OK', this.ok, this);
    ...
        ok: function() {
    
            if(this.preventAsync) {
                this.el.submit();
                //this.el.dom.submit();            
                //this.el.dom.form.submit();
                return;
            }
            ...
        }
    But I'm really in doubt about what element to use to trigger submit(). I've been trying for a couple of hours to get this simple thing working... so any clues would make me happy. :-)

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Submit the form element!

    So if you've constructed the dialog from a form as you indicate:

    Code:
    this.getEl().dom.submit();
    el is the same as getEl(), so that middle commented line should have worked.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    122
    Vote Rating
    0
    moraes is on a distinguished road

      0  

    Default


    Solved!

    Oh well, yes, I've tried that and that's why I was so confused (this.el.dom.submit() should work!). Knowing that I was in the right track helped a lot, thanks.

    Now I discovered that the problem was caused by a hidden field with name and id "submit" that the form had (it is generated by a framework which adds the hidden fields to force a default value for submits). I don't know why the hidden field avoids the form submission, but at least now I know that I need to remove it.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    That's pretty dumb of the framework to create an input field called "submit"! It's a name collision, so you'll have been trying to call the field, rather than a function.

    You should have been getting the error

    "this.el.dom.submit is not a function"

    In the Firebug console which should have been a clue that the object exists but isn't a function.

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    122
    Vote Rating
    0
    moraes is on a distinguished road

      0  

    Default


    Quote Originally Posted by Animal
    That's pretty dumb of the framework to create an input field called "submit"!
    It's a pretty smart framework but indeed nobody is perfect! :lol:

    I'm writing to the developers to report this problem and see what they think and if the field should be renamed or there are other workarounds. Thanks for the info! :-)

    update: they agreed and the hidden field name/id will be changed. ;-)

Similar Threads

  1. BasicDialog in JSF: Submit a Form without Ajax, revisited
    By tromanow in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 26 Jul 2007, 5:45 AM
  2. ID of submit within form masks submit function
    By aconran in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 19 Feb 2007, 12:08 AM
  3. Basic Dialog Form plus submit example?
    By rob30UK in forum Ext 1.x: Help & Discussion
    Replies: 26
    Last Post: 13 Jan 2007, 9:11 AM
  4. BasicDialog with one TabPanelItem a try to submit form
    By JuanParraC in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 4 Dec 2006, 12:15 AM
  5. Basic Dialog and form submit
    By JC in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 21 Nov 2006, 12:44 AM

Thread Participants: 1