Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
Im trying to display individual cell pop up in html table.Only first row cells are showing pop up...Here is my code


XML
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script>


<style>
th
{
border-bottom: 1px solid #d6d6d6;
}
tr:nth-child(even)
{
background:#e9e9e9;
}
</style>
</head>
<body>
 <div data-role="header">
    <h1>Page Title</h1>
</div>

<script id="itemTemplate" type="text/x-jquery-tmpl">
            <tr>
        //  alert("hi");
                <td>${FileName}</td>
                <td>${Parid}</td>
                <td>${Rank}</td>
                <td>${Year}</td>
                  <td>${CapturedBy}</td>
                <td>${CapturedDate}</td>
                <td>${Image}</td>
            </tr>
        </script>

        <table id="itemList" border="1" style="cursor: pointer;"  data-role="table" class="ui-responsive" data-mode="columntoggle"  data-column-btn-text="Click me to hide or shown columns!"  >
            <thead>
                <tr>

                    <td>FileName</td>
                   <td>Parid</td>
                    <td>Rank</td>
                    <td>Year</td>
                   <td>CapturedBy</td>
                    <td>CapturedDate</td>
                     <td>Image</td>

                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>

 <script type="text/javascript">

            $(document).ready(function(){
            alert("dps1");
                var items = [
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },
                    { FileName: "Apple", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" },

                    { FileName: "Banana", Parid: "80", Rank : "3", Year : "240", CapturedBy: "80", CapturedDate : "3", Image : "240" }
                ];

                $( "#itemTemplate" ).tmpl( items ).appendTo( "#itemList tbody" );
            });

        var tbl = document.getElementById("itemList");
        if (tbl != null)
        {
      //  alert("dps");

            for (var i = 0; i < tbl.rows.length; i++)
            {
                for (var j = 0; j < tbl.rows[i].cells.length; j++)
                {
                  //    alert(tbl.rows.length);
                    tbl.rows[i].cells[j].onclick = function () { getval(this); };
                    alert(tbl.rows.length);
                }
            }
        }

        function getval(cel) {

    alert(cel.innerHTML);


        }

        </script>


  <div data-role="footer">
    <h1>Footer Text</h1>
  </div>
</div>

</body>
</html>
Posted
Comments
Kornfeld Eliyahu Peter 21-Jul-14 9:08am    
What the value of tbl.rows.length?
Dev Sharma 21-Jul-14 9:53am    
returning 1..
Kornfeld Eliyahu Peter 21-Jul-14 9:58am    
I hope that answers your question...
I do not work with templates, but it seems to me that appending data to the template does not update row count...You have to investigate...
Dev Sharma 21-Jul-14 10:02am    
Hi,
How to update row count.Any idea....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900