Note that there are some explanatory texts on larger screens.

plurals
  1. POobservable not updating when in a hidden div
    text
    copied!<p>I have an observable binding to a textarea within a hidden div like so:</p> <pre><code>&lt;span title="sales comment" data-bind="attr: { id: 'sales-'+year() }" style="cursor :pointer;"&gt; &lt;img src="information.png" alt="Add comment" /&gt; &lt;/span&gt; &lt;div data-bind="attr: { id: 'sales-'+year()+'_content' }" style="display : none;"&gt; &lt;textarea data-bind="value: salesComment, valueUpdate: 'keydown'"&gt; &lt;/textarea&gt; &lt;/div&gt; </code></pre> <p>and viewModel</p> <pre><code>var FinancialYearViewModel = function(data, parent) { var self = this; self.year = ko.observable(); self.salesComment = ko.observable(); }; ko.applyBindings(new FinancialHistoryViewModel(data)); var data = {"year": "2012", "salesComment": "sales comment"} </code></pre> <p>The hidden div is used to populate the content of a qtip tooltip like this:</p> <pre><code>$(document).ready(function() { $("span[title]").each(function(i) { content = $("#" + this.id + "_content").html(); $(this).qtip({ content: { text: content }, show: { event: 'click' }, hide: { event : 'unfocus'} }); }); }); </code></pre> <p>The viewModel binds ok and qtip displays the hidden div as its content as required. However when the textarea value changes the viewModel does not update.</p> <p>It does work when I remove the inline css from the div, i.e:</p> <pre><code>&lt;div data-bind="attr: { id: 'sales-'+year()+'_content' }"&gt; &lt;textarea data-bind="value: salesComment, valueUpdate: 'keydown'"&gt; &lt;/textarea&gt; &lt;/div&gt; </code></pre> <p>But I need to hide the contents of the div by default as it's used only when a user views a qtip.</p> <p>Any ideas why this css is preventing the observable from updating the viewModel?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload