0

Most input controls are top-level divs in HTML, with a descendent <input>. When the page first loads, e.g. when .OnInitialized of the control is triggered, the HTML control div has no children yet.

I would like to run some JavaScript when the descendent <input> is rendered onto the page.

@(Html.DevExtreme().SelectBox()
    .ID("mycontrol")
    .InputAttr("onload", "alert('loaded!')")

Even though inspect element reveals this kind of structure

<div id="mycontrol" ...>
    ...
    <input onload="alert('loaded!')" aria-haspopup="listbox" role="combobox" ...>

The onload attribute is right there!

But the onload attribute never fires, the alert never triggers, no matter what javascript I put there it doesn't run.

So how can I run some javascript when the descendent <input> appears?

theonlygusti
  • 9,142
  • 8
  • 49
  • 93

0 Answers0