Note that there are some explanatory texts on larger screens.

plurals
  1. PO2 way binding doesn't work
    primarykey
    data
    text
    <p>When I click the save link for a new blog topic, the console output is empty values for the topic object. When I click the save link for a existing blog topic, the output is the old values for the topic object.</p> <p>Why isn't the values being assigned the property when the save link is clicked?</p> <pre><code> var viewModel = function(topics){ var self = this; self.topics = ko.observableArray(topics); self.editing_topic = ko.observable(""); self.new_topic = function(){ self.edit_topic({}); } self.edit_topic = function(topic){ self.editing_topic(topic); form.dialog({width:800, height:600, modal:true}); }; self.save_topic = function(){ console.log(self.topic()); }; }; ko.applyBindings(new viewModel(jsondata)); &lt;fieldset class="blog_topic_form" title="New Blog Entry"&gt; &lt;div&gt; &lt;label for="topic_title"&gt; Title: &lt;/label&gt; &lt;input type="text" id="topic_title" data-bind="value: topic().topic_title"/&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="message_contents"&gt; Message: &lt;/label&gt; &lt;textarea id="message_contents" class="message_contents" data-bind="value: topic().message_contents"/&gt; &lt;/div&gt; &lt;footer&gt; &lt;a class="save_link" data-bind="click: save_topic"&gt;&lt;/a&gt; &lt;a class="cancel_link"&gt;&lt;/a&gt; &lt;/footer&gt; &lt;/fieldset&gt; </code></pre> <p>Edit: Here is the jsfiddle: <a href="http://jsfiddle.net/jLkxG/3/" rel="nofollow">http://jsfiddle.net/jLkxG/3/</a></p> <p>When you run it, it will assign the default values. However, if you edit the textbox and click savelink, it will output the original (initial) values instead of the values entered in the textbox. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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