0

Whenever I dynamically change the value of an input field ($("#test").val("test") or $("#test").value = "test") then physically click the field then exit the input the value reverts back to "". Physically changing the value retains the value.

I have tried:

- physically removing all event listeners on the page in Chrome DevTools
- $("input").off();
- $("input").click(function(e) { 
    e.preventDefault();
    e.stopImmediatePropagation(); 
    return false;
  });
  $("input").blur(function(e) { 
    e.preventDefault();
    e.stopImmediatePropagation(); 
    return false;
  });
  $("input").focusout(function(e) { 
    e.preventDefault();
    e.stopImmediatePropagation(); 
    return false;
  });

I have checked network traffic and nothing has changed on change.

The system uses React, dojo, dijit if that is relevant / helps.

Thanks for any assistance!

freedomn-m
  • 27,664
  • 8
  • 35
  • 57
Mech
  • 3,952
  • 2
  • 14
  • 25
  • 2
    Are you able to reproduce the issue on a new page, or, ideally, in a stack snippet here? – freedomn-m Sep 27 '21 at 15:54
  • 1
    Unfortunately not. I think there lies the problem. I am having trouble identifying the root cause. – Mech Sep 27 '21 at 15:58
  • I don't know enough about [tag:dijit.form], but is it possible that it *replaces* your `` tag with its own UI? ("dijit contains form *widgets*"). You could try: `$("input").val("test").change()` to trigger a change event so that the "widget" updates the UI *and* its internal store of the value. **edit** as described here: https://dojotoolkit.org/reference-guide/1.7/dijit/form.html#id6 – freedomn-m Sep 27 '21 at 16:55
  • https://dojotoolkit.org/reference-guide/1.7/dijit/form/TextBox.html#dijit-form-textbox suggests: `dijit.byId("your_id").set("test")` – freedomn-m Sep 27 '21 at 17:00
  • Thanks for the responses. There is no widgetid so I don't think I can use `dijit.byId` unless I am completely missing the mark. – Mech Sep 29 '21 at 17:04
  • I only got that from looking at the digit help pages - perhaps it's not wijit? Whenever a third part *replaces* your inputs, apply DOM/jquery events to the original elements will have no effect - you need to apply the events to the replacement UI. – freedomn-m Sep 29 '21 at 17:06

0 Answers0