<script custom-tag="" type="application/ld+json">{"@context":"https://schema.org","@type":"TechArticle","headline":"Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag","image":"http://support.servicenow.com/29f1d2661baf6010cafa53d8624bcb43.iix","author":{"name":"ServiceNow Support","url":"http://support.servicenow.com/now"},"keywords":"ServiceNow, NowSupport public Knowledge Base articles, Known Error,KB0863528,","wordcount":"190","publisher":"ServiceNow","url":"https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0863528","datePublished":"2020-11-04","dateCreated":"2020-11-03","dateModified":"2023-11-21","description":"<h2>Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag</h2><br/><div style=\"overflow-x:auto\"><h2>Description</h2><div><p>When adding an onchange attribut","articleBody":"<h2>Custom UI: Reference macro doesn't bubble change event when handler defined on g:ui_reference tag</h2><br/><div style=\"overflow-x:auto\"><h2>Description</h2><div><p>When adding an onchange attribute to a reference macro (using the g:ui_reference), the onchange listener is not triggered when the value of the reference macro is set via an ATF step Set Component Values (Custom UI) or via the Page Inspector.</p></div><h2>Steps to Reproduce</h2><div> <p></p><p>1. Create a sys_ui_page with the following content:<br />&lt;?xml version&#61;&#34;1.0&#34; encoding&#61;&#34;utf-8&#34; ?&gt;<br />&lt;j:jelly trim&#61;&#34;false&#34; xmlns:j&#61;&#34;jelly:core&#34; xmlns:g&#61;&#34;glide&#34; xmlns:j2&#61;&#34;null&#34; xmlns:g2&#61;&#34;null&#34;&gt;<br />&lt;g:ui_reference name&#61;&#34;usrrequestor&#34; query&#61;&#34;active&#61;true&#34; id&#61;&#34;usrrequestor&#34; table&#61;&#34;sys_user&#34; value&#61;&#34;&#34; onchange&#61;&#34;console.log(&#39;### OnChange Fired&#39;);&#34;/&gt;<br />&lt;/j:jelly&gt;<br /><br />2. Open the ui page and open the ATF Page Crawler<br />3. Select the element and set its value to any value<br />4. Look at the console<br /><br />Behavior: Console logs do not contain &#34;### OnChange Fired&#34;<br />Expected: Console logs should contain that log statement</p></div><h2>Workaround</h2><div><p>A change event is fired from a different, not-instrumented, element of the reference macro&#39;s expansion. This change event bubbles and can be caught via an element which holds the reference macro (such as a div). When manually setting the reference macro&#39;s value, this event is fired when clicking away from the reference macro after setting its value.</p></div><div><br /><strong>Related Problem: PRB1442253</strong></div></div>"}</script>
  Loading...