You need to be logged in to post in the forum - Log In

An active JCE Pro Subscription is required to post in the forum - Buy a Subscription

Support is currently Online

Official support hours
Monday to Friday
09:00 - 17:00 Europe/London (BST)

#104727 JCE in repeatable subforms

Posted in ‘Editor’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by pixxelfactory on Friday, 03 July 2020 08:20 BST

pixxelfactory
Hi, we are using Subforms in Joomla to provide dynamic block-style layouts for our clients (so that they can add, edit, delete and sort blocks of content). However there is one big issue: When creating editor-fields, as soon as you start to drag the subform-row, all the content inside editor-fields in that row will be eliminated instantly. The joomla-devs know about this issue a long time, but don't care: https://github.com/joomla/joomla-cms/issues/24343 So we tried to fix it on our own, modifying two javascript files: - media/system/js/subform-repeatable.js: We modified its code so that a subform-row-sort event gets triggered everytime a user drags a subform-row:

// bind move button
		if(this.options.btMove){
			this.$containerRows.sortable({
				items: this.options.repeatableElement,
				handle: this.options.btMove,
				tolerance: 'pointer',
				stop: function(event, ui) {
					var $row = ui.item[0];
					self.$container.trigger('subform-row-sort', $row);
				}
			});
		}
And media/editors/tinymce/js/tinymce.min.js, inside the setupEditor function we add a condition wich eliminates the editor prior to rebuilding it if it exists alread:

if (element) {
				// We already have the Target, so reset the selector and assign given element as target
				options.selector = null;
				options.target   = element;

				var editor = tinymce.get(element.id);

				if (editor) {
					editor.remove();
					delete Joomla.editors.instances[element.id];
				}
			}
That way drag-and-drop works inside subforms, but only using the tinymce editor wich is aweful & terrible. We tried to figure out if there is any way to fix this behaviour with jce... Can you help us? Thanks in advance Best regards

Ryan
I have fixed this in JCE Pro 2.8.15 Beta 3 - https://www.joomlacontenteditor.net/downloads/editor/pro/development/jce-pro-2-8-15-dev

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

pixxelfactory
Hi Ryan,

thanks for your response.
Tried it, unfortunately it didn't work, i attached two videos, one the behaviour with the jce-beta, the other with the tinymce (wich i fixed).
Maybe i need to do other adjustments to the joomla-script?

Thanks for your help!
Best regards

Ryan
This is because of the "update" option in the sortable config, which means the event is only triggered if there is an actual sort. I have updated the PR to use "stop" instead - https://github.com/joomla/joomla-cms/pull/29898

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

pixxelfactory
Hi Ryan,

ah, you're the same ryan like the one on the joomla-repo on github =D
I already use the stop-event (as a matter of fact, i requested the change in the pr on github).
And the same setup works with the crappy standard-tinymce, wich i modified as mentioned in the first post. =/

Best regards

Ryan
It is working in my tests now with the stop event.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

pixxelfactory
I've just setup a new testing environment with a clean joomla-installation to exclude possible problems because of modifications i may did to the old testing site:

- Joomla 3.9.19
- JCE Beta (installed and set as default editor)
- created a content plugin wich shows a repeatable subform in joomla-articles
- created a simple module with repeatable editors
- applied the pr-modifications on the subform-repeatable.js

But it still does not work =/
Can i send you the login to the test-site?

Thanks
Best regards

Ryan
- created a content plugin wich shows a repeatable subform in joomla-articles


Please attach your content plugin files as a zip for me to test with.

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

pixxelfactory
Hi,

thanks! I've added the module and content-plugin to the zip.

Attachments

module.zip

Ryan
Please try beta 4 - https://www.joomlacontenteditor.net/downloads/editor/pro/development/jce-pro-2-8-15-dev

Ryan Demmer

Lead Developer / CEO / CTO

Just because you're not paranoid doesn't mean everybody isn't out to get you.

pixxelfactory
Hi Ryan,

thanks! That did it!!! =)

Best regards