kunal s

kunal s

  • NA
  • 1
  • 2.2k

Mvc3 append javascript function to link in html table generated from JSON

May 11 2012 5:09 AM
I have following content in my view file (.cshtml)

 function FillFeedCharges()
        {
         

           var link;
         
            var idModel = $("#sGroup_cd").val();
            if (idModel != "") {
                $.getJSON("@Url.Content("~/GroupMast/List")", { sGroup_cd: idModel, sCompany_cd :"01"},
                function (data) {
               
              var header = '<tr><td>&nbsp;&nbsp;&nbsp;'  + '</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>' + '<td>Description' + '</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>'   +  '<td>' + 'DateStarted' + '</td>'+ '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + 'AvgCalories' + '</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + 'Pounds' + '</td>'  + '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + 'Cost' + '</td>' +'</tr>' ;
               $('#users table').append(header);
               $.each(data, function (key, val) {
             
                   var user = '<tr><td>'+'<a onclick='+'javascript:CallEditDetail()'+'>Click here</a>' +'</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>'   + '<td>' + val.Description + '</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>'   +  '<td>' + val.DateStarted + '</td>'+ '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + val.AvgCalories + '</td>' + '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + val.Pounds + '</td>'  + '<td>&nbsp;&nbsp;&nbsp;</td>'  +'<td>' + val.Cost + '</td>' +'</tr>';

                 
             
                   $('#users table').append(user);

               });
          });


when i Called 'CallEditDetail' function in  $(document).ready(function ()  it is not callled and give error as 'CallEditDetail not declared' and if i called from outside the $(document).ready(function ()  it is called. Please help me