Skip to content

Improve form JS init selector#2049

Merged
mvorisek merged 16 commits intodevelopfrom
fix_form_init_selector
May 22, 2023
Merged

Improve form JS init selector#2049
mvorisek merged 16 commits intodevelopfrom
fix_form_init_selector

Conversation

@mvorisek
Copy link
Copy Markdown
Member

@mvorisek mvorisek commented May 21, 2023

related with #1275 and fomantic/Fomantic-UI#2792

@mvorisek mvorisek force-pushed the fix_form_init_selector branch from d78d010 to 5e7b105 Compare May 21, 2023 14:47
@mvorisek mvorisek force-pushed the fix_form_init_selector branch from 733e8ac to 5b181e7 Compare May 21, 2023 20:06
@mvorisek mvorisek force-pushed the fix_form_init_selector branch from e303679 to d7342c2 Compare May 21, 2023 23:11
if ($this->buttonSave) {
$this->buttonSave = $this->layout->addButton($this->buttonSave);
$this->buttonSave->setAttr('tabindex', 0);
$jsSubmit = $this->js()->form('submit');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoke div.ui.form submit, thanks to l138, the submit will be sent to the native form tag.

@mvorisek mvorisek marked this pull request as ready for review May 22, 2023 07:53
@mvorisek mvorisek changed the title Fix form JS init selector Improve form JS init selector May 22, 2023
parent::init();

$this->formElement = View::addTo($this, ['element' => 'form', 'shortName' => 'form'], ['FormElementOnly']);
$this->on('submit', new JsExpression('if (event.target === this) { []; }', [$this->formElement->js()->trigger('submit')]));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main point of this PR, dispatch native event without instantiating Fomantic-UI form behaviour for the native form tag.

@mvorisek mvorisek force-pushed the fix_form_init_selector branch from eb04a59 to 84def7b Compare May 22, 2023 07:56
@mvorisek mvorisek force-pushed the fix_form_init_selector branch from 84def7b to a1d86a6 Compare May 22, 2023 07:58
@mvorisek mvorisek merged commit 02da37a into develop May 22, 2023
@mvorisek mvorisek deleted the fix_form_init_selector branch May 22, 2023 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant