? Success

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
25 Mar 2015

PR #3484 introduced the ability to bind jquery functionality on submit form event. The problem is that this doesn’t fire as expected as observed on #6207.

What is changed?

Instead of submit

        jQuery(form).submit();

it should be:

        jQuery(form).trigger("submit");

Test instructions:

Apply patch
Open /administrator/components/com_content/views/article/tmpl/edit.php
and insert

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

just before ? > at around line 75

Try to create (save) an article, you should get in browsers log works

OR follow these instructions

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

hm, this is very strange, as under the hood submit() and trigger("submit") the same thing, jQuery source

avatar dgt41
dgt41 - comment - 25 Mar 2015

I think in core.js we pass the form object and trigger submit() and somehow things get messed up with a form id "adminForm" which is not always the case, or something like that was the logged stuff on my test! It’s really weird but I think it is down to the form selector and there the code gets confused and never fire any bind functionality. I hope that this comment makes some sense

avatar Fedik
Fedik - comment - 25 Mar 2015

I think I know reason, problem not in submit() and trigger("submit"),
it just missed in minified version of the core.js file :smile:

avatar Fedik
Fedik - comment - 25 Mar 2015

here you update the minified version and it works now,

so test good, thanks! :wink:

avatar Fedik Fedik - test_item - 25 Mar 2015 - Tested successfully
avatar Fedik
Fedik - comment - 25 Mar 2015

betwen, I thought about something like this http://stackoverflow.com/a/18072246/1000711
in theory it should be more generic,it vanilla, it trigger "real" DOM event, and it trigger html5(!!!) validation :metal:

avatar Fedik
Fedik - comment - 25 Mar 2015

another thought, about merging the javascript files, that have minified version,
would be a lot more safe to create the minified version after merge, not before ... because something tell me that GIT cannot merge them good, if was used different tools for this

avatar dgt41
dgt41 - comment - 25 Mar 2015

@Fedik Thanks, yes the problem is not trigger or submit, I didn’t check the minified file
About vanilla script: bring it on, and I will close this one

avatar infograf768
infograf768 - comment - 26 Mar 2015

Tested in #6207 and works fine.

avatar Fedik
Fedik - comment - 26 Mar 2015

@dgt41 there it is #6587

avatar dgt41
dgt41 - comment - 26 Mar 2015

Please test #6587 as that is a FAR BETTER implementation! Thanks @Fedik

avatar dgt41 dgt41 - change - 26 Mar 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-03-26 14:04:35
avatar dgt41 dgt41 - close - 26 Mar 2015
avatar dgt41 dgt41 - close - 26 Mar 2015
avatar dgt41 dgt41 - head_ref_deleted - 26 Mar 2015

Add a Comment

Login with GitHub to post a comment