Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set value of input field inside jquery UI dialog

I'm trying to change the value of input field with jquery. The input field is inside UI dialog box. It's part of my zend form

<input name="formulaCategory" id="formulaCategory" value="" size="40" type="text">

I have a link calls for a function that shows the dialog and I want it to change the value of this input as well.

function editFormulaCategoryDialog() {

    $("#edit-formula-category-dialog").dialog({show: "slide"});
    $("#formulaCategory").val('test');
}

Why it doesn't work?

If I put the input code somewhere else on the page outside dialog box and click the same link the dialog box shows up and the value of input field outside dialog is changed as expected.

like image 485
kasztelan Avatar asked Nov 23 '25 03:11

kasztelan


1 Answers

Try this:

function editFormulaCategoryDialog() {

    $("#edit-formula-category-dialog").dialog({
        show: "slide",
        create: function() {
            $("#formulaCategory").val('test');
        }
    });
}

Try with a callback after dialog box create. You can also use open event callback.

like image 169
thecodeparadox Avatar answered Nov 24 '25 23:11

thecodeparadox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!