Conversation
|
Nice to see these PRs to apply things like styling and behaviour on a specific container function JSfunction(..., container)
{
container = container || document;
$(container).find('.classname')....
....
}i had suggested this in the past, but i got a negative answer, i do not remember why, now with the subform, the need for this is more obvious
currently i am using my own API to do such things |
|
@ggppdk The reason this is able to work is that subform is emitting First, Joomla could set a listeners at the document level the react to Of course, we'd rather be using Mutation Observers but that's just not something we can realistically rely on right now. Or maybe we can but provide something like a polyfill for older browsers? Another thing that might be nice would be to have a new Joomla core js function like |
|
Actually, now that I think about it, a function like But if Joomla had its own ready function, we could just do it like this: Then, typically, any functions you pass will just get handled by the jQuery ready event anyway but that could be replaced as needed. Additionally, the init function you pass could be called when changes are made to the dom. We'd probably want to specify this behavior with a flag or something. Maybe like: The function should expect to be passed either I haven't given it much thought yet but it seems like a good idea. |
Please don't do that. ECMAScript 6 is widely supported from every html5 browser and there is: |
Remember that Joomla still supports IE8 |
|
I have tested this item ✅ successfully on 3c29533 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12993. |
|
@DGT41 Vanilla JS is just fine but, without mutation observers, it doesn't solve the problem of dom updates. |
|
@okonomiyaki3000 you can use a polyfill for mutation observer: https://github.com/megawac/MutationObserver.js. |
|
@DGT41 please remember that J3.x is around for at least 30 more months
…On 28 November 2016 at 15:08, Dimitri Grammatikogianni < ***@***.***> wrote:
@okonomiyaki3000 <https://github.com/okonomiyaki3000> you *can* use a
polyfill for mutation observer: https://github.com/megawac/
MutationObserver.js.
and therefore use it safely even for IE8. My personal opinion (and that's
all there is here) is to stick to javascript standards as much as possible.
This might come with a slight cost for 3.x (polyfills) but will be a
cleaner base for J4 (>IE11).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#12993 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABPH8QRNPMD6KeKTJN9Llttg3URtRSWOks5rCu56gaJpZM4K7MQB>
.
--
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
https://brian.teeman.net/ <http://brian.teeman.net/>
|
|
@brianteeman we already introduced polyfills in other instances (e.g. tinyMCE) so that shouldn't be a problem. Also I am aware of the EOL for 3.x and I don't see a possible conflict here, but maybe I'm missing something... |
|
You'd still end up with every bit of init code needing to set up a handler for DOMContentLoaded and then also add some mutation observer code. This gets pretty redundant when you have chosen, tooltips, calendar, etc all on the same page and all setting these things up. That's why I think it's not bad for Joomla to provide a function that takes your init function and applies it whenever needed. |
|
I have tested this item ✅ successfully on 3c29533 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12993. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12993. |
|
@DGT41 can you please confirm that the problem is fixed in the final stage? I'm not sure at this stat of the PR that the issue you discussed is finaly fiexed now? |
|
@zero-24 this PR is fine as is, go ahead and merge it! |
|
Done thanks 👍 |
|
Hello, I really do like the idea and that chosen within the subforms are resolved, but I also really don't like the idea of a depending event in chosen just for subforms. It should be the other way arround: Chosen should offer a function ($.fn.chosen e.g.) which can be used by other javascripts and then THEY can add events etc. |
|
@bembelimen actually joomla should move away from chosen. Reason well explained here: harvesthq/chosen#1740 (comment) |
|
On long term, I fully agree @DGT41 on short term perhaps we should change the Joomla! behavior? |
|
@bembelimen No that is not the way it should be. In that scenario, each and every control type that needs some kind of initialization in javascript (there are many) would need to provide such a function and subform would need to be aware of all of them. This is barely maintainable for the standard field types but it breaks down completely when you consider that it's possible to write custom field types. You are right that the current approach is not perfect but look at it like this. So we should look at other possibilities going forward but this is good for now. |
Pull Request for Issue # .
Summary of Changes
When adding a new row in a subform that contains one or more selects that should be turned into 'chosen', chosen initialization will be run on the new row's elements.
This was originally part of #12542 but separating it to keep PRs small and simple.
Testing Instructions
Add new rows to any subform that contains 'chosen'. Before this change, they should remain as regular selects. After, they will be proper chosens.
Documentation Changes Required
No