Carlota
Carlota

Reputation: 1237

jquery dialog how to get id element fires dialog

I have a jstl with some input texts. The input text field is

<input type="text"   id="<c:out value="nombre-nuevo-${identificador}"/>"  value="<c:out value="${celda.nombre}"/>" onclick="displayCombo()"/>

When I click this input field I want to open a dialog window. The window definition is

 $("input[id*=nombre-nuevo]").click(function() {
            $( "#dialog-combo-incidencias" ).dialog({
                resizable: false,
                height: 140,
                modal: true,
             buttons: [{
          text: "Yes",
          click: function() {
            alert($(this).attr('id'));
            $(this).dialog("close");
          },
        }, {
          text: "No",
          click: function() {
          alert($(this).attr('id'));
            $(this).dialog("close");
          },
        }

      ],
    });

I want to load the value selected in the window in the input field which opens the window.

How can I set the value of window in the input text?

Upvotes: 0

Views: 36

Answers (1)

Cerlin
Cerlin

Reputation: 6722

Can you try the below code?

$("input[id*=nombre-nuevo]").click(function(event) {
    let inputField = event.target
    $( "#dialog-combo-incidencias" ).dialog({
        resizable: false,
        height: 140,
        modal: true,
        buttons: [
            {
                text: "Yes",
                click: function() {
                    alert($(inputField).attr('id'));
                    $(this).dialog("close");
                },
            }, {
                text: "No",
                click: function() {
                    alert($(inputField).attr('id'));
                    $(this).dialog("close");
                },
            }
        ]
    });
});

Upvotes: 1

Related Questions