? ? Pending

User tests: Successful: Unsuccessful:

avatar cheesegrits
cheesegrits
24 Nov 2017

Pull Request for Issue # .

Summary of Changes

The 'showon' feature for forms doesn't currently provide a setup method when adding a new form to the DOM on the fly, rather than on domready. There's a way to add a repeated instance to an existing form, which uses some additional data attributes to add repeat numbering, but my use case involves adding new forms in the backend through AJAX.

This change just renames setUpShowon as Joomla.setUpShowon, so it can be called through the global Joomla object..

Testing Instructions

Pick any backup param that has showon, like global settings "send mail". Apply this change. The showon feature still works. :)

Expected result

Actual result

Documentation Changes Required

None

avatar cheesegrits cheesegrits - open - 24 Nov 2017
avatar cheesegrits cheesegrits - change - 24 Nov 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 24 Nov 2017
Category JavaScript
avatar Fedik
Fedik - comment - 24 Nov 2017

your fix is incorrect,
subform script do not have subform-container-add event,

to fix what you asked you should call setUpShowon from your ajax script, but first setUpShowon need to be under Joomla.setUpShowon scope

avatar cheesegrits
cheesegrits - comment - 24 Nov 2017

OK, so how do we achieve that?

-- hugh

avatar Fedik
Fedik - comment - 25 Nov 2017

for Joomla! 3:
you can make a pull request to rename setUpShowon to Joomla.setUpShowon,
so you can use it in your script:

function ajaxCallback() {
 // do your stuf ...
 var blablaContainer = ...;
 // call setUpShowon
 Joomla.setUpShowon(blablaContainer);
}

for Joomla! 4 there will be a custom events, see #16016 ,
so you will be able to do in your script:

function ajaxCallback() {
 // do your stuf ...
 var blablaContainer = ...;
 // dispatch custom event to inform about DOM updates
 Joomla.Event.dispatch(blablaContainer, 'joomla:updated');
}
avatar franz-wohlkoenig franz-wohlkoenig - change - 25 Nov 2017
Status Pending Information Required
avatar cheesegrits cheesegrits - change - 11 Dec 2017
The description was changed
avatar cheesegrits cheesegrits - edited - 11 Dec 2017
avatar cheesegrits
cheesegrits - comment - 11 Dec 2017

@Fedik - hopefully this is now the right way to do it?

avatar Fedik
Fedik - comment - 11 Dec 2017

@cheesegrits yes, looks good now ?

avatar cheesegrits
cheesegrits - comment - 11 Dec 2017

@Fedik - cool.

BTW, where's a good place to bounce some stuff off you about the event dispatcher in 4.0, as it relates to bootstrap? I've run across an immediate use for it, related to the same issue I'm addressing here, of adding entire forms to the DOM. Similar problem, that the bootstrap-init.js only runs on domready. I've patched it locally in 4.0 to add your joomla:updated event handling, but that raised a problem with Joomla.loadOptions() ...

I guess I can go ahead an do a PR for those changes, and maybe get your input there?

avatar Fedik
Fedik - comment - 12 Dec 2017

@cheesegrits you can check #16016 as starting point, there introduced Joomla.Event.dispatch in core.js
and #18864 as an example how it can work

I guess I can go ahead an do a PR for those changes, and maybe get your input there?

I do not know about a plans for bootstrap-init.js in Joomla! 4, but yes, any help are welcome ?

avatar cheesegrits
cheesegrits - comment - 15 Dec 2017

@Fedik - can you give the green light for this one? Then I can submit the bootstrap-init one.

avatar Fedik Fedik - test_item - 15 Dec 2017 - Tested successfully
avatar Fedik
Fedik - comment - 15 Dec 2017

I have tested this item successfully on 2423a5c

on review,
this just rename setUpShowon to Joomla.setUpShowon without logic changes,
and this changes allow to extension developers to easily use showon feature with their AJAX code, or other dynamic code


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18843.

avatar Fedik
Fedik - comment - 15 Dec 2017

@cheesegrits but if you need it only for Joomla! 4, then there it is fixed b10572d (in another way)

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 24 Dec 2017

@cheesegrits any Statement on Comment above by @Fedik?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18843.

avatar cheesegrits
cheesegrits - comment - 24 Dec 2017

@franz-wohlkoenig oops, sorry, misread his comment and didn't think it needed a response. I need this functionality in 3.x and 4.x. So yes, still need this merged.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18843.

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Dec 2017
Status Information Required Discussion
avatar Sophist-UK
Sophist-UK - comment - 7 Feb 2018

I have tested this item successfully on 2423a5c

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Feb 2018

@Fedik can you please retest?

avatar Quy
Quy - comment - 7 Feb 2018

Do you have to apply the same changes to cms.js?

avatar Sophist-UK
Sophist-UK - comment - 7 Feb 2018

Presumably cms.js is the compressed version.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Jul 2019

@Fedik can you please retest?

avatar Fedik
Fedik - comment - 21 Jul 2019

I have tested this item successfully on 2423a5c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18843.

avatar Fedik Fedik - test_item - 21 Jul 2019 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 21 Jul 2019
Status Discussion Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 21 Jul 2019

Status "Ready To Commit".

avatar HLeithner
HLeithner - comment - 22 Jul 2019

are we sure that setUpShowon only lives in the closure and is private till this PR?

avatar Fedik
Fedik - comment - 22 Jul 2019

@HLeithner I did not seen it anywhere else in the core ?

avatar HLeithner
HLeithner - comment - 22 Jul 2019

@Fedik what happens if you execute setUponshown multiple times on body? Wouldn't the animation be executed several times?

avatar Fedik
Fedik - comment - 23 Jul 2019

hm yes, probably ?

But the idea is to call it once per new container, example when part of the page was updated dynamically,
that the case with "subform row".

Currently this was "isolated".
After this patch Joomla.setUpShowon() can be called by extension developers, who want update the form dynamically (via ajax example), and be able to use ShowOn feature.

avatar HLeithner
HLeithner - comment - 23 Jul 2019

Programmers are lazy, they will simply use the form as container... is there a simple way to prevent the double attach?

avatar Fedik
Fedik - comment - 23 Jul 2019

I can think about 2 way:

  • set some flag to the container itself, that should be easy
  • set some flag per field with "showon", that more safe but may need a bit more work

Can be as a data attribute data-showon-attached="true" or something similar

avatar HLeithner
HLeithner - comment - 26 Jul 2019

Would be good, jQuery('input').data('shown-attached', true); should be easy to implement.

Can you do this?

avatar Fedik
Fedik - comment - 28 Jul 2019

me? yea, I guess :)

I just thought, is it worth to do it for j3.
Because for j4 Joomla.setUpShowon no need, there already used joomla.updated event.

avatar HLeithner
HLeithner - comment - 8 Aug 2019

Removing RTC and hope @Fedik find time to implement jQuery('shown-attached').

avatar jwaisner jwaisner - change - 23 Apr 2020
Status Ready to Commit Pending
avatar gostn
gostn - comment - 24 Nov 2020

set label ´Updates Requested´ again.

avatar gostn
gostn - comment - 10 Jan 2021

reminder:

Removing RTC and hope @Fedik find time to implement jQuery('shown-attached').

avatar Fedik
Fedik - comment - 16 Jan 2021

I have forked this, please have a look #32061

avatar richard67
richard67 - comment - 16 Jan 2021

Closing in favour of #32061 . Thanks @cheesegrits for this PR here as a base for the fix.

avatar richard67 richard67 - close - 16 Jan 2021
avatar richard67 richard67 - change - 16 Jan 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-01-16 13:46:42
Closed_By richard67
Labels Added: ?

Add a Comment

Login with GitHub to post a comment