javascript - Knockout with HTML table issue -



javascript - Knockout with HTML table issue -

basically, have page displays multiple tables, populated knockout. rows show in grid unless populated info (special status rows). have ko subscribed observable observes whether or not there info in row. within subscription function says:

self.requestsubscription = self.hasrequest.subscribe(function (newvalue) { if (newvalue) { $("[rowid = '6']").show(); // 6 hardcoded } else { $("[rowid = '6']").hide(); } });

problem is, function goes through every grid on page (cause forgot that's how jquery works) , hides row in every grid. how can cut down hiding grow in current grid? problem can't hardcode id's grids because don't know how many grids show on page load. ideas? thanks!

here html minus unnecessary content. markup grid itself. problem is, when hide tr id "6" jquery above, every 1 of these grids on page.

<table> <tbody> <!-- ko foreach: rows() --> <tr data-bind="css: { 'request': id() === 6, 'conflict': id() === 8}, attr: { rowid: id() }"> <td class="title-cell"> <span data-bind="text: title(), attr: { typeid: id() }">booking type</span> </td> </tr> </tbody> </table>

instead of showing , hiding row jquery, should take advantage of knockout's visible binding. this:

<tr data-bind="visible: mytablemodel.hasspecialcondition"> <td>whatever</td> </tr>

that way display logic connected info instead of dom.

documentation here: http://knockoutjs.com/documentation/visible-binding.html

javascript jquery html knockout.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -