www.webdeveloper.com
Results 1 to 2 of 2

Thread: dynamically appended items doesn't work

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    dynamically appended items doesn't work

    this function appends into html document .
    $(document).ready(function() {
    $("body").ready(function (e) {
    var showId = $("#showId").val();
    var sId = $("#sId").val();
    var offSet = $("#offSet").val();
    var rowsPerPage = $("#rowsPerPage").val();
    var db = $("#db").val();
    var dataString = 'sId=' + sId + '&db=' + db + '&showId=' + showId + '&offSet=' + offSet + '&rowsPerPage=' + rowsPerPage;
    /*alert("sname:="+ytpl1);
    alert("sid="+sId);
    alert("showID="+showId);*/
    jQuery.ajax({
    type: "GET",
    url: "/upload/videoupdate.php",
    data: dataString,
    success:function(response){
    var myArray = $.parseJSON(response);
    var htmldata ='';

    for (var i = 0; i < myArray.length; i++)
    {
    var obj = myArray[i];
    /*alert(obj.id);*/
    htmldata=htmldata+'<div class ="videowrapper well" id="'+obj.id+'"><form class="video" id="'+obj.id+'" action="" method="post">VideoName:<br/><input type="content_txt" value="'+obj.yt_title+'" class="videoName" ><br>Description:<br/><input type="content_txt" value="'+obj.description+'" class="description"><br><input class="videosubmit" id="'+obj.id+'"type="button" value="Update" ><input class="delBtn" id="'+obj.id+'" type="button" value="delete" ></form><div class="video1"><img src="'+obj.thumb_medium+'"height="180" width="320"></div></div>';

    }
    /*alert(myArray.length);*/
    $("#responseWrapper").append(htmldata);
    },
    error:function (){
    alert("Insert a valid playlist Id");
    }
    });

    });


    });

    and it is the code which on click executes but its not working need help

    $(document).ready(function() {


    $(".videosubmit").on('click',function (e) {

    var id= this.id; alert(id);
    });

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671
    1. using [code]your code goes here[/code] tags can significantly increase your chance of getting help
    2. it's not clear what exactly doesn't work or what error(s) are you getting
    3. try this

    Code:
    $(document).ready(function() {
    $(".videosubmit").on('click',function(e){
    var id= $(this).attr('id');alert(id);
    });

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles