Marko
Marko

Reputation: 1595

jQuery .load and links are not clickable anymore?

I'm updating some data from sidebar when I click one element on mainside. When it's updating data from external file (calling same query what is in original sidebar) those links are not clickable any.

Here is clip from my custom.js

$(function() {
  $(".removeItem").click(function() {
    var commentContainer = $(this).parent();
    var id = $(this).attr("itemID");

    var string = 'itemID='+ id;

    $.ajax({
      type: "POST",
      url: "getRemove.php",
      data: string,
      cache: false,
      success: function(){
        $("#basket").load("getBasketUpdate.php");
      }
    });

    return false;
  });

});

Well as most can read this clearly, i'll explain it anyway. When user want's to remove item from basket, clicks del link and item is removed from database, after that, update basket sidebar whit fresh data (remove item is gone)..

Anyways, after that, when hit del item button, nothing happens!

Thanks for all help!!

Upvotes: 1

Views: 1009

Answers (3)

Marko
Marko

Reputation: 1595

Actually one question about .live!

Can it be use for just .load?

Code:

$(".editme1").editInPlace({
    url: "getEdit.php",
    params: "mode=cat",
    show_buttons: true,
        success: function(){
            $("#links").load("getLinks.php");
        }
});

Where user edit container .editme1 (where can edit category name) and when success it will update category list. Now I have on this category list sort function where clicking cat name it will show only those items. When I edit cat name, it'll update list but when click cat name it won't work.. ?? :(

Thanks again for all help!

Upvotes: 0

ticallian
ticallian

Reputation: 1641

As phoenix stated, change line

$(".removeItem").click(function() 

to

$(".removeItem").live('click',function() 

That should do the trick.

Upvotes: 0

rahul
rahul

Reputation: 187020

You can use the

live

function

Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.

replace

$(".removeItem").click(function() {

with

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

Upvotes: 4

Related Questions