views:

253

answers:

3

Hi.

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!!

+4  A: 

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(){
rahul
Oh man.. so easy! I've tryed search sollution couble hours and I just didn't catch this.. damn! Thanks you phoenix and ticallian..
Marko
A: 

As phoenix stated, change line

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

to

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

That should do the trick.

ticallian
A: 

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!

Marko