javascript - Row click event within jquery click function is not working only for last row -
I am creating a dynamic table in the form shown below. I need user clickable rows To another page It works just fine till the last but one line. Clickable row functionality does not exist in the last line.
$ (window) .load (Function () {$ .get ("http: // localhost: 8080 / music player / getsloglist", function (data) {console.log (data) ; Var library = data; var table = $ ("# table"); Var line; library. Songs.for every (work (song) {line = $ ("& lt; tr & gt; & lt; / tr & Gt; "); $ (" & lt; td />").addClass("Song-select ") .append ($ (" & lt; input />").attr({type:"checkbox " , Class: "checkbox" | value: song.title})). AppendTo (row); $ ("& lt; Td" "+ song.title +" & lt; / td & gt; "). Attachments (Line); $ ("& lt; td>" + song.album.albumName + "& lt; / td & gt;"). Attachment (line); $ ("& lt; td> + Song.artist + "& lt; / td>"). Attachment (line); $ ("& lt; t D & gt; "+ song.rating +" & lt; / td & gt; "). Attachment (line); $ (" & lt; td> "+ song.composer +" & lt; / td & Gt; ") appendTo (line). $ (" & Lt; td> "+ song.genre.genreName +" & lt; / td & gt; "). AppendTo (row); row.appendTo (table) .click (viewFunction ());});});}); }); Function Scene Function () {$ ('# Table broken TR TD: no (.song-select)'). Click (function () {var songTitle = $ (this) .Parent (). Children ('td: eq (1)'). Text (); window location. ("Http: // localhost: 8080 / music player / Get Song? Songtital = "+ song title);}); }
Check it out. You have been used instead of the View function.
$ (function () {$ .get ("http: // localhost: 8080 / music player / gate songlite", function (data) {console log (data); var library = data ; Var table = $ ("# table body"); var line; library. Songs.for each (function (song) {line = $ ("& lt; tr & gt; & lt; / tr & gt;") .data ('song-title', song.title); $ ("& lt; td />int).addClass("song-select").append($(<input/ & gt;"). Attr ({type: "checkbox", category: "checkbox", value: song.title})). Appendo (line); $ ("& lt; td>" + song.title + "& lt; / Td & gt; ") .appendTo (line); $ (" & lt; td> "+ song.album.albumName +" & lt; / td & gt; "). Annex (Punk B); $ ("& lt; td>" + song.artist + "& lt; / ADDTO (line); $ (" & lt; td> "+ song.composer +" & lt; AD & T (Line); $ ("& lt; td>" + song.rating + "& lt; / td>; / Td & gt;"). Attachment (line); $ ("& lt; td & Gt; "+ song.genre.genreName +" & lt; / td & gt; "). Attachment (line); line.appendTo (table);});});}); $ ('# Table Tables '). ('Click', 'td: no (.song-select)', function () {var songTitle = $ (this) .Parent () .data ('song-title'); location = "http: // localhost : 8080 / Music Player / Get Song? Song title = "+ song titul;)); });
Comments
Post a Comment