In a client script, we have a dialog.create box t...
# suitescript
d
In a client script, we have a dialog.create box that shows a dropdownlist with location values. We're using a JQuery .change to set the value on the dropdown change but that is not being triggered. Anyone have any ideas why? jQuery("#elementId").change(function () { console.log("on change"); // not seing this, not triggered selectedValue = jQuery("#elementId").find(":selected").val(); });
e
When are you calling
dialog.create
and
$.change
?
d
In the same function. It's on a button click. I tried putting the
.change
in the pageInit and other places but no luck thus far.
e
FWIW
My guesses would be that the target field isn't wired to fire the
change
event, or the handler is being assigned before the target field exists
d
Yes, that makes sense. Thanks for the input. I'll try the
.on
as well.
e
You can confirm that your selector returns the element you think it does before you assign the handler
👍 1
d
BTW, great stuff you and Tim are doing with the webinars! Kudos!
❤️ 1
@erictgrubaugh Just to confirm, in suitescript it would look like this? jQuery("#elementId").on("change", function () { })
e
Yeah, think so
👍 1
You can store the selected element in a variable and log it out to inspect it while troubleshooting
Copy code
const target = jQuery("#elementId")
console.log(target)
target.change(() => {
  console.log("on change")
  selectedValue = target.find(":selected").val()
})
d
It appears
target
is empty. 😡 This only recently stopped working so it could have been a NS update. Not sure. The client script runs on a button click on a new address form. Maybe it's the popup within the address form pop up window that broke. Also tried putting stuff in the DOM but no luck. Ugh.