Rectangle 27 57

I had the same problem and based on the 1.10.0 version of jquery ui, I think you should try

data('uiAutocomplete')

instead of

data('autocomplete')

Based on Johnny's comment, I checked how the .data() function works. Yes, jQuery returns null from .data() call when selector does not find any items.

So if there is no matching element for your selector, then no autocomplete object is created and added to the custom data object.

$(selector).autocomplete({ your autocomplete config props here });
    if ( $(selector).data() ) {

    // some jQueryUI versions may use different keys for the object. so to make sure,
    // put a breakpoint on the following line and add a watch for $(selector).data(). 
    // then you can find out what key is used by your jQueryUI script.

        var ac = $(selector).data('uiAutocomplete');
        if ( ac ) {
           // do what you want with the autoComplete object. below is the changed version of an example from jqueryUI autocomplete tutorial

           ac._renderItem = function(ul, item) {
                return $("<li>")
                    .append("<a>" + item.label + "</a>")
                    .appendTo(ul);
            };
        }
    }

Why don't they update the documentation with each release, this is so annoying. Thanks anyway.

Maybe that's because one of the two things we developers hate most is documenting things ? :) And the second must be filling timesheets I suppose

data('uiAutocomplete') doesn't work for me. Also currently on the jquery-ui demo website they have it as data('ui-Autocomplete'). I think the issue is the .data property itself. It is not defined, no matter with what argument you call it.

In my version, it is absolutely "uiAutocomplete". You can debug it with Chrome and you'll see the name of the attribute by calling .data()

JQuery 1.7.2 / JQueryUI 1.10.2 - I'm finding both uiAutocomplete and ui-Autocomplete work just fine!

jQuery Autocomplete .data("autocomplete") is undefined - Stack Overflo...

jquery autocomplete undefined jquery-autocomplete
Rectangle 27 5

Ha! Phil: you rock!!! It is an old project I'm working on. And forgot it was still using 1.4.2. Time for an upgrade.

html5 - HTML's data attribute undefined in jQuery - Stack Overflow

jquery html5 custom-data-attribute
Rectangle 27 8

data('ui-Autocomplete') resolved my troubles. I think it's from jquery 1.7 with jquery-ui 1.8. data('autocomplete') was ok. The same script with a recent version of these files doesn't work.

jQuery Autocomplete .data("autocomplete") is undefined - Stack Overflo...

jquery autocomplete undefined jquery-autocomplete
Rectangle 27 1

If you look at the latest example of combobox on the site demo, you will see they use data('ui-Autocomplete'). I ran into the same problem as you. I was previously using jquery-1.6.2 and jquery-ui-1.8.16. Once I updated my files to jquery-1.9.1 and jquery-ui-1.10.0 the error was fixed. I assume the older jquery-ui autocomplete was not setting the data('ui-Autocomplete') property, therefore it was null/undefined when retrieved. I hope this helps other people since you probably already fixed the issue.

jQuery Autocomplete .data("autocomplete") is undefined - Stack Overflo...

jquery autocomplete undefined jquery-autocomplete
Rectangle 27 15

You need to have data in your table before you can call the sortList method on it. This is because you apply an indexing in this method that will not find any records if there is no data present and that will throw the "Cannot read property '0' of undefined" error.

jQuery TableSorter Plugin error on init : cannot read property '0' of ...

jquery jquery-plugins tablesorter
Rectangle 27 5

$.ajax returns immediately return data which is executed before the function you passed as success callback was even called.So its return as undefined .Its means you can't return ajax data .

success: function(json) {
            data=json;
            $( '#res1' ).html( data[0].swlat );  
            $( '#res2' ).html( data[0].swlat ); 
        }

Thank you for that link, I was thinking the problem is something like this yeah. I don't really need to show data in div, this was just for demonstration of my problem, I only wanted to use JSON data outside ajax function. However I'll solve this with a callback.

javascript - Using JSON data retrieved with AJAX outside success funct...

javascript jquery json ajax
Rectangle 27 5

$.ajax returns immediately return data which is executed before the function you passed as success callback was even called.So its return as undefined .Its means you can't return ajax data .

success: function(json) {
            data=json;
            $( '#res1' ).html( data[0].swlat );  
            $( '#res2' ).html( data[0].swlat ); 
        }

Thank you for that link, I was thinking the problem is something like this yeah. I don't really need to show data in div, this was just for demonstration of my problem, I only wanted to use JSON data outside ajax function. However I'll solve this with a callback.

javascript - Using JSON data retrieved with AJAX outside success funct...

javascript jquery json ajax
Rectangle 27 13

alert(data[currCounter])

as data.currCounter looks for the key 'currCounter` in the object, not by the value of currCounter.

var myObj = { 'name':'dhruv','age':28 };
var theKey = 'age';
alert(myObj.theKey);  // undefined
alert(myObj[theKey]); // 28

Thanks @DhruvPathak .. It just worked by using [] instead of "."

JSON values parsed as undefined in javascript - Stack Overflow

javascript json jquery
Rectangle 27 13

alert(data[currCounter])

as data.currCounter looks for the key 'currCounter` in the object, not by the value of currCounter.

var myObj = { 'name':'dhruv','age':28 };
var theKey = 'age';
alert(myObj.theKey);  // undefined
alert(myObj[theKey]); // 28

Thanks @DhruvPathak .. It just worked by using [] instead of "."

JSON values parsed as undefined in javascript - Stack Overflow

javascript json jquery
Rectangle 27 13

alert(data[currCounter])

as data.currCounter looks for the key 'currCounter` in the object, not by the value of currCounter.

var myObj = { 'name':'dhruv','age':28 };
var theKey = 'age';
alert(myObj.theKey);  // undefined
alert(myObj[theKey]); // 28

Thanks @DhruvPathak .. It just worked by using [] instead of "."

JSON values parsed as undefined in javascript - Stack Overflow

javascript json jquery
Rectangle 27 3

In JavasSript there are 5 primitive data types String , Number , Boolean , null and undefined. I will try to explain with some simple example

lets say we have a simple function

function test(a) {

     if(a == null){
        alert("a is null");
     } else {
        alert("The value of a is " + a);
     }
  }

also in above function if(a == null) is same as if(!a)

now when we call this function without passing the parameter a

test(); it will alert "a is null";
   test(4); it will alert "The value of a is " + 4;
var a;
alert(typeof a);

this will give undefined; we have declared a variable but we have not asigned any value to this variable; but if we write

var a = null;
alert(typeof a); will give alert as object

so null is an object. in a way we have assigned a value null to 'a'

What is the difference between null and undefined in JavaScript? - Sta...

javascript null undefined
Rectangle 27 3

In JavasSript there are 5 primitive data types String , Number , Boolean , null and undefined. I will try to explain with some simple example

lets say we have a simple function

function test(a) {

     if(a == null){
        alert("a is null");
     } else {
        alert("The value of a is " + a);
     }
  }

also in above function if(a == null) is same as if(!a)

now when we call this function without passing the parameter a

test(); it will alert "a is null";
   test(4); it will alert "The value of a is " + 4;
var a;
alert(typeof a);

this will give undefined; we have declared a variable but we have not asigned any value to this variable; but if we write

var a = null;
alert(typeof a); will give alert as object

so null is an object. in a way we have assigned a value null to 'a'

What is the difference between null and undefined in JavaScript? - Sta...

javascript null undefined
Rectangle 27 3

In JavasSript there are 5 primitive data types String , Number , Boolean , null and undefined. I will try to explain with some simple example

lets say we have a simple function

function test(a) {

     if(a == null){
        alert("a is null");
     } else {
        alert("The value of a is " + a);
     }
  }

also in above function if(a == null) is same as if(!a)

now when we call this function without passing the parameter a

test(); it will alert "a is null";
   test(4); it will alert "The value of a is " + 4;
var a;
alert(typeof a);

this will give undefined; we have declared a variable but we have not asigned any value to this variable; but if we write

var a = null;
alert(typeof a); will give alert as object

so null is an object. in a way we have assigned a value null to 'a'

What is the difference between null and undefined in JavaScript? - Sta...

javascript null undefined
Rectangle 27 3

//Allow manually entered text in drop down.
createSearchChoice:function(term, data) {
  if ( $(data).filter( function() {
    return term.localeCompare(this.text)===0; //even if the this.text is undefined it works
  }).length===0) {
    return {id:term, text:term};
  }
},

//solution to this error: Uncaught TypeError: Cannot read property 'localeCompare' of undefined

twitter bootstrap - Select2 dropdown but allow new values by user? - S...

twitter-bootstrap jquery-select2
Rectangle 27 3

//Allow manually entered text in drop down.
createSearchChoice:function(term, data) {
  if ( $(data).filter( function() {
    return term.localeCompare(this.text)===0; //even if the this.text is undefined it works
  }).length===0) {
    return {id:term, text:term};
  }
},

//solution to this error: Uncaught TypeError: Cannot read property 'localeCompare' of undefined

twitter bootstrap - Select2 dropdown but allow new values by user? - S...

twitter-bootstrap jquery-select2
Rectangle 27 3

//Allow manually entered text in drop down.
createSearchChoice:function(term, data) {
  if ( $(data).filter( function() {
    return term.localeCompare(this.text)===0; //even if the this.text is undefined it works
  }).length===0) {
    return {id:term, text:term};
  }
},

//solution to this error: Uncaught TypeError: Cannot read property 'localeCompare' of undefined

twitter bootstrap - Select2 dropdown but allow new values by user? - S...

twitter-bootstrap jquery-select2
Rectangle 27 7

Resolve/Reject both accept a single parameter ... hence why your result is undefined, as the second value you pass to resolve is never used, and the first is null

UsersRepo.findOneAsync({id: id}).then(function(result) {
    console.log("UserService promise resolution", result);
}).catch(function(err) {
    console.log("UserService promise error", err);
});

findOneAsync: function(args) {
    var where = ""; //omitted

    var promise = new Promise(function(resolve, reject) {
        db.query("Select * from users" + where + " limit 1", function(err, result) {
            var res = { id: 1, username: 'username', firstName: 'First', lastName: 'Last' };

            if(err != null) {
                console.log("REJECT", err);
                reject(err);
            }
            else {
                console.log("RESOLVE", res);
                resolve(res);
            }
        });
    });

    return promise;
}

javascript - Bluebird promise resolve(data) is undefined in client cod...

javascript node.js promise bluebird
Rectangle 27 5

jquery-ui-1.10.3.min.js

Your issue is caused by duplicating your jQuery UI core scripts.(check if you are including any other librady such as jquery-ui-1.10.3.drag-drop.min.js .

Load just them once, and your issue will go away.

In this vein, check your AppStart/BundleConfig.cs. Comment everything out and add the jquery to the front-end to test. This is what did it for me; there were obviously bundled librar(ies) interfering with the javascript loading.

javascript - JqueryUI Datepicker: Uncaught TypeError: Cannot read prop...

javascript jquery jquery-ui
Rectangle 27 7

Somepeople think that "ui-autocomplete" is wrong, so they use "autocomplete" or "uiAutocomplete", but that is wrong. Actually, "ui-autocomplete" is the right way to do this.

I have the same issue you have, and I find with a friend the problem of this code. Instead:

.data('ui-autocomplete')._renderItem = function (ul, item) {
       if (!_.include(self.idArr, item.id)) {
            return $('<li></li>').data('ui-autocomplete-item', item).append('<a>' + item.name + '</a>').appendTo(ul);
            }
    };
._renderItem = function (ul, item) {
      if (!_.include(self.idArr, item.id)) {
         return $('<li></li>').data('ui-autocomplete-item', item).append('<a>' + item.name + '</a>').appendTo(ul);
           }
       };

I think combobox and autocomplete returns a data('ui-autocomplete'), so if you type .data('ui-autocomplete') you're doing something like:

.data('ui-autocomplete').data('ui-autocomplete')

What's wrong....well, actually I don't know why this don't work and why without this works, but trust me, delete .data('ui-autocomplete') and be happy!

jQuery Autocomplete .data("autocomplete") is undefined - Stack Overflo...

jquery autocomplete undefined jquery-autocomplete
Rectangle 27 2

if($(this).data(which) === undefined && Object.keys($(this).data()).length > 0)

Juvian - I looked you up and you're spamming downvotes. I will not accept your answer unless you correct that, because all of the answers work technically.

@NicholasHazel: How would you determine that?

@NicholasHazel as explained, havent made a single downvote today, just had my answer downvoted as well and that gives -2 rep as well

javascript - How to determine if an element has NO data-attr - Stack O...

javascript jquery html custom-data-attribute