? Success

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
26 Mar 2015

Currently Joomla.submitform method do not trigger native 'submit' DOM event, that make a lot problem.
And this pull allow to do this.

Some benefits:

  • it trigger native 'submit' DOM event
  • it use vanilla javascript
  • it can trigger HTML5 input validation (by default disabled for BC reason)

how to test
put this code into index.php in the template:

<script>
jQuery(document).ready(function($){
    var form = document.getElementById('item-form');
    if(!form){
        return;
    }

    // test native
    var method = document.addEventListener ? 'addEventListener' : 'attachEvent',
        event  = document.addEventListener ? 'submit' : 'onsubmit';
    form[method](event, function(){
        alert('Well done! Push OK!');
    });

    // test jquery, any other library
    $(form).on('submit', function(){
        return confirm('Continue ???');
    });
});
</script>

go to edit article form, and try save/cancel/apply ...

expected result
after each push on toolbar button you should get 2 popup,
and if on question 'Continue ???' you push "Cancel" form should not be submitted.

actual result
nothing happens

Also this pull require more than 2 simple test,
Need make sure that other forms also works as before,
Need make sure that this work in IE, and other browser that Joomla! promised to support.

I hope this finally solve such problems #6580, #3484, #5914, #6384

avatar Fedik Fedik - open - 26 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 26 Mar 2015
Labels Added: ?
avatar dgt41
dgt41 - comment - 26 Mar 2015

@test ok
also with code:

JFactory::getDocument()->addScriptDeclaration('
jQuery(document).ready(function() {
    jQuery("#item-form").bind("submit", function() {
        console.log("works");
    });
});
');

And with the last iteration of #6207
Nice one @Fedik Thanks!

avatar phproberto
phproberto - comment - 27 Mar 2015

Cool :+1:

@test ok

avatar phproberto phproberto - change - 27 Mar 2015
Title
Improve Joomla.submitform
Improve Joomla.submitform
Labels Added: ?
avatar zero-24 zero-24 - change - 27 Mar 2015
Status Pending Ready to Commit
avatar Fedik
Fedik - comment - 27 Mar 2015

sorry guys, I did one more update,
because if you have form <form id="adminForm" novalidate> and try submit it Joomla.submitform('task', 'adminForm', true); validation still will be disabled.
my last commit fix it

avatar zero-24 zero-24 - change - 27 Mar 2015
Status Ready to Commit Pending
avatar zero-24 zero-24 - change - 27 Mar 2015
Category JavaScript
avatar wilsonge wilsonge - change - 28 Mar 2015
Labels Removed: ?
avatar dgt41
dgt41 - comment - 29 Mar 2015

@test still ok

avatar zero-24 zero-24 - alter_testresult - 29 Mar 2015 - dgt41: Tested successfully
avatar dgt41
dgt41 - comment - 4 Apr 2015

@wilsonge Can I ask for a 3.4.2 milestone here. The reason is that a regression due to removal of mootools needs this, the issue is here: #6207 with a working solution but with a dependency for this code. Thanks

avatar wilsonge wilsonge - change - 4 Apr 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-04-04 17:04:58
avatar wilsonge wilsonge - close - 4 Apr 2015
avatar wilsonge wilsonge - reference | - 4 Apr 15
avatar wilsonge wilsonge - merge - 4 Apr 2015
avatar wilsonge wilsonge - close - 4 Apr 2015
avatar zero-24 zero-24 - close - 4 Apr 2015
avatar zero-24 zero-24 - close - 4 Apr 2015
avatar dgt41
dgt41 - comment - 4 Apr 2015

Wow, that was fast!

avatar zero-24 zero-24 - change - 4 Apr 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment