Uncaught TypeError: Object [object Object] has no method 'open'

I have this JS code:

$( document ).ready( function() {

    $( "#dialog" ).dialog({
            modal: true,
            autoOpen: false
        });

    $( "input[name=age]" ).change( function() {
        $( "#dialog" ).open();

        $.get( '/viewer?tool=10&age=' + $( this ).val(), function( data ) {
            $( "#dialog" ).close();            
        });
    });
});

      

When I change the value of the name input "age" I have this error in the console:

Uncaught TypeError: Object [object Object] has no method 'open'

I have added scripts correctly to the head of my HTML document and the call to .dialog throws no errors.

If I change the code to:

$( document ).ready( function() {

    $( "#dialog" ).dialog({
            modal: true,
            autoOpen: false
        });

    $( "input[name=age]" ).change( function() {
        $( "#dialog" ).dialog( "open" );

        $.get( '/viewer?tool=10&age=' + $( this ).val(), function( data ) {
            $( "#dialog" ).dialog( "close" );            
        });
    });
});

      

Everything works fine.

How do you explain this?

Thank!

0


source to share


1 answer


JQuery's standard collection has no method open

. The jQuery UI adds a dialog method to collections that you can use to instantiate and manipulate the dialog.



+3


source







All Articles