? Success

User tests: Successful: Unsuccessful:

avatar fredden
fredden
22 Apr 2014

This means that the event listeners in the HTML5-fallback library (which use jQuery) are also triggered. See JoomlaCode issue: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33312

avatar fredden fredden - open - 22 Apr 2014
avatar fredden fredden - change - 22 Apr 2014
Title
Also calls jQuery events on form submission
[#33312] Also calls jQuery events on form submission
avatar beat
beat - comment - 22 Apr 2014

If you want to do this jQuery-correct way, you should call $(form.classOfForm).submit(); This allows to prevent the default form submit if wanted (e.g. for validations):

http://api.jquery.com/submit/

avatar nicksavov nicksavov - change - 21 Aug 2014
Labels Removed: ?
avatar brianteeman brianteeman - change - 21 Aug 2014
Status New Pending
avatar brianteeman brianteeman - change - 2 Sep 2014
Category JavaScript
avatar dgt41
dgt41 - comment - 8 Mar 2015

@test success
Needs also the same mods in the compressed file!

Test instructions:
Apply patch
Enable debug
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

screen shot 2015-03-09 at 12 35 57

avatar dgt41
dgt41 - comment - 8 Mar 2015

@fredden Can you update the code as it says that there are conflicts?
Also can you apply the mod to the compressed file?

avatar fredden fredden - reference | - 9 Mar 15
avatar fredden
fredden - comment - 9 Mar 2015

Okay, I've updated this pull request. Hopefully that's the correct procedure.
I've not tested this on a real site, but the Travis CI build passed.

avatar dgt41
dgt41 - comment - 9 Mar 2015

This form.classOfForm doesn’t work. Sorry I should have comment on that before, as I tried that recommendation but I forgot to write about it!

avatar fredden
fredden - comment - 9 Mar 2015

Thanks. Ideally I'd have tested before committing. Updated per your example @dgt41, still untested by me.

avatar dgt41
dgt41 - comment - 9 Mar 2015

@Fedik @Anibalsanchez can you take a look at this one?
@beat did you mean something like this:

        var formClass = jQuery(form).attr("class");
        jQuery(form, "."+formClass).submit();

?

avatar Fedik
Fedik - comment - 9 Mar 2015

in theory should be enough just jQuery(form).submit() or jQuery(form).trigger('submit');.
I do not know what the reason to use some tricky formClass, the form could be without any class

avatar dgt41
dgt41 - comment - 9 Mar 2015

@Fedik This works with no problems for me as well, but @beat mentioned that an extra class selector should be in place. I think this is not necessary as we are triggering the event for a specific object, so I don’t see how this can conflict somehow with, lets say another form in the page...

avatar Fedik
Fedik - comment - 9 Mar 2015

well, I do not see info that can confirm it on http://api.jquery.com/submit/
quick test show that it will not work, and form will be submitted when you trigger submit event on form element ... unless I missed something :smile:

avatar dgt41
dgt41 - comment - 9 Mar 2015

This allows to prevent the default form submit if wanted

That was the exact reason @beat mentioned in the comment above, but I am not sure what he means or how this can be tested!

avatar Fedik
Fedik - comment - 9 Mar 2015

This allows to prevent the default form submit if wanted

this do not prevent, just try :wink:

Maybe something like this can only trigger, and then submit by form.submit():

if(jquery){
  jQuery(form).submit(function (event) {
    event.preventDefault();
  });
  jQuery(form).submit();
}
form.submit()

but I do not see much sense it this :smile:

avatar anibalsanchez
anibalsanchez - comment - 10 Mar 2015

I concur, no need of tricky formClass. Besides, I could have to add more classes.

avatar dgt41
dgt41 - comment - 10 Mar 2015

So @Fedik @anibalsanchez @beat we all agree that this formClass is not needed?
@fredden Can I ask you to revert this without my and @beat ’s suggestion?

avatar dgt41 dgt41 - test_item - 10 Mar 2015 - Not tested
avatar dgt41 dgt41 - test_item - 10 Mar 2015 - Tested successfully
avatar dgt41
dgt41 - comment - 10 Mar 2015

@Fedik @anibalsanchez can you test it? @fredden reverted to the original jQuery(form).submit();

avatar Fedik
Fedik - comment - 10 Mar 2015

test works good for me

avatar zero-24 zero-24 - change - 10 Mar 2015
Status Pending Ready to Commit
avatar zero-24 zero-24 - alter_testresult - 10 Mar 2015 - Fedik: Tested successfully
avatar zero-24
zero-24 - comment - 10 Mar 2015

RTC based on testing Thanks!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3484.
avatar brianteeman brianteeman - change - 13 Mar 2015
Labels Added: ?
avatar mbabker mbabker - change - 15 Mar 2015
Milestone Added:
avatar mbabker mbabker - change - 15 Mar 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-03-15 16:41:48
avatar mbabker mbabker - close - 15 Mar 2015
avatar mbabker mbabker - close - 15 Mar 2015
avatar dgt41
dgt41 - comment - 25 Mar 2015

@mbabker It seems that the solution provided here doesn’t work for all cases e.g. #6207 (last comments)
Do we need a new PR to change it to jQuery(form).trigger("submit"); or this can be done here?

avatar mbabker
mbabker - comment - 25 Mar 2015

Do it as a PR please. I manually merged this one due to conflicts and had to triple check myself when merging the compressed file changes; at least a PR (hopefully) has the right changes :smiley:

avatar dgt41
dgt41 - comment - 25 Mar 2015

ok will do that

Add a Comment

Login with GitHub to post a comment