Wednesday, July 23, 2014

Wednesday, July 2, 2014

jQuery not working after the content is loaded through AJAX



$(document) refers to the whole document.
$(document).on('click', "#click", function () {
    $('#click').css({
        "background-color": "#fff",
        "color": "#000",
        "cursor": "inherit"
    }).text("Open this window again and this message will still be here.");
    return false;
});


jquery with page loaded by ajax

 
  $(document).on('click', "#checkall", function () {
    $(".tours_table tr").not(".tours_table tr:eq(0)").click(function(){
       $(this).toggleClass("selecting");
    });
   
    $("#checkall").change(function () {
    $(".tours_table table input:checkbox").prop('checked', $(this).prop("checked"));
    });
   
    $(".tours_table table input:checkbox").not("#checkall").change(function(){
       if($("#checkall:checkbox").attr("checked","checked")){
        $("#checkall:checkbox").removeAttr("checked");}
    });
  
  
  });

ajax with codeigniter

function delete1(){
        var  num_record1 = new Array();
    $('.checkname1:checked').each(function () {
        var e = $(this);
        num_record1.push(e.val());
    });
            var showarray=new Array();
        $.ajax({
            type:'post',
            url:'deletetours',
            data:{showarray:num_record1},
            success: function(data) {
                $("#showtype").html(data);
                }
                ,
            error: function() {
                alert('error');
            }
        });
    //});
}