kubus lemiszewwski
kubus lemiszewwski

Reputation: 51

TypeError: $(...).live is not a function

I received this error in the next function:

TypeError: $(...).live is not a function
$(".gem").live("click", function () {
    if (gameState == "pick") {
        posY = $(this).position().top;
        posX = $(this).position().left;
        $("#marker").show();
        $("#marker").css("top", posY - 5).css("left", posX - 5);
        if (selectedRow == -1) {
            selectedRow = (posY - 10) / 60;
            selectedCol = (posX - 10) / 60;
        } else {
            posY = (posY - 10) / 60;
            posX = (posX - 10) / 60;
            if ((Math.abs(selectedRow - posY) == 1 && selectedCol == posX) || (Math.abs(selectedCol - posX) == 1 && selectedRow == posY)) {
                $("#marker").hide();
                gameState = "switch";
                gemSwitch();
            } else {
                selectedRow = posY;
                selectedCol = posX;
            }
        }
    }
});

Upvotes: 0

Views: 12115

Answers (6)

Tiago Peres
Tiago Peres

Reputation: 15441

I had this same problem on my Weblog and this was creating a problem of when clicking in "Select All" in the Updates page, wouldn't select all

enter image description here

From the Console could see that error and instructions pointing to the file update-core.php. Clicking there, it'd open the file in Source

Fast Carousel problem

and the problem is in

$('#fastcarousel-generator-insert').live('click', function(event) {

that should have been

$('#fastcarousel-generator-insert').on('click', function(event) {

Going to that specific file on my server and searching for .live wasn't enough because there was no such line in there. Then, spotted from the sentence with .live that it had #fastcarousel in it.

After disabling that plugin, then the "Select All" functionality started working again.

Upvotes: 0

user3123035
user3123035

Reputation:

http://api.jquery.com/live/

"As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live()."

Already removed in the newest version. Use

$(".gem").on('click', '<insert element containing .gem here>', function(){

http://api.jquery.com/on/ look for "Direct and delegated events"

Upvotes: 0

milagvoniduak
milagvoniduak

Reputation: 3254

Try using jquery on method

$(".gem").on('click', function() { ... });

https://api.jquery.com/on/

https://api.jquery.com/live/ - deprecated

Upvotes: 1

Quentin
Quentin

Reputation: 943207

live is not a function

So look it up in the jQuery documentation.

A search gives the API page which says:

version deprecated: 1.7, removed: 1.9

and

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.

Upvotes: 0

john Smith
john Smith

Reputation: 17906

.live() is deprecated, change it to .on()

Upvotes: 0

Rahul Tripathi
Rahul Tripathi

Reputation: 172398

Try replacing live with on in your code

$(".gem").live("click",function(){

replace with

$(".gem").on("click",function(){

.live() is deprecated in older version(1.7 onwards) of JQuery so you need to use .on()

From the docs:

"As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live()."

Upvotes: 7

Related Questions