Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger "change" event after updating user field input value #21323

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Trigger "change" event after updating user field input value #21323

merged 1 commit into from
Jul 31, 2018

Conversation

ryandemmer
Copy link
Contributor

@ryandemmer ryandemmer commented Jul 31, 2018

Summary of Changes

The onchange event is not triggered on a form element when the element's value is updated programmatically, only on user input, therefore a "change" event must be dispatched when the user id field value is set.

Without dispatching a change event, the change event listener created for the data-onchange attribute is not triggered, and the associated function is not called.

Testing Instructions

Edit administrator/components/com_content/forms/article.xml and set an onchange attribute for the create_by field, eg:

<field 
    name="created_by" 
    type="user"
    label="COM_CONTENT_FIELD_CREATED_BY_LABEL"
    onchange="(function(){console.log('change')})()" 
/>

Create or edit an article, and in the Options tab, select a new user for the Created By field.

Expected result

In the browser console, "change" should be displayed when the new user is selected.

Actual result

Nothing is displayed in the console as a change event is not triggered.

Documentation Changes Required

None.

@ryandemmer ryandemmer changed the title Trigger "onchange" event after updating input value Trigger "change" event after updating user field input value Jul 31, 2018
@wilsonge wilsonge merged commit d98337b into joomla:4.0-dev Jul 31, 2018
@wilsonge wilsonge added this to the Joomla 4.0 milestone Jul 31, 2018
@ryandemmer
Copy link
Contributor Author

Thank you @wilsonge !

@wilsonge
Copy link
Contributor

Thankyou!

@ryandemmer
Copy link
Contributor Author

This PR, although merged into 4.0-dev, does appear to have been dropped at some stage.

I would imagine this may have happened when the files were moved from media/system/webcomponents/js/ to media/system/js/fields/

The issue still exists, as you can see here - https://github.com/joomla/joomla-cms/tree/4.0-dev/media/system/js/fields/joomla-field-user.js

@brianteeman
Copy link
Contributor

@ryandemmer please create a new issue and refer to this one - already merged and closed issues rarely get noticed. Thanks

@ryandemmer
Copy link
Contributor Author

Done - #29404 - Thanks @brianteeman :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants