Use case
I have custom JS that reacts on a change event in a select list. When webform conditionals are use to alter the value of the select list, the change event is not triggered. Is there a reason for this?

Comments

Mirakolous created an issue. See original summary.

mirakolous’s picture

I am attaching a patch that resolves my specific issue. Hopefully this can make its way into the module at some point. I am not sure what the downside is, yet.

liam morland’s picture

Version: 7.x-4.16 » 7.x-4.x-dev
Status: Active » Needs review

I don't know of any reason for change not being triggered.

geoffreyr’s picture

I've been looking into doing some work with conditionals as well, and this applies to text fields as well. Since changes to text fields aren't applied through $.webformVal(), and since $.webformVal() is only used during Drupal.webform.doConditions, I'm taking the alternate approach of triggering a change event on all applicable selects and text fields after the value has been updated.

This appears to be pretty essential for making it work well with Webform Calculator formulae.

varshith’s picture

I agree @geoffreyr
But I think it would be better if only trigger a 'change' when 'actionResult' is set. That way we only do it when we actually set values and not otherwise. I have an updated patch attached.

liam morland’s picture

Status: Needs review » Needs work

There will need to be a comment in the added code documenting why it is there.

mirakolous’s picture

This patch still applies for me. I have added a comment to it. Let me know if the wording should change and I can adjust.

liam morland’s picture

Thanks. Please add a period to the end of the comment, check your indentation, and put the patch in an issue fork.

liam morland’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.