knockout.js

knockout valueUpdate not working with Pagedown?

拜拜、爱过 提交于 2019-12-22 09:22:47
问题 I have the following in my view: <textarea data-bind="value: content, valueUpdate: 'afterkeydown'"></textarea> Which when typing, behaves as I'd expect. But I'm using a WMD / Pagedown editor to click a button that adds content to the field, much like StackOverflow's post contents box when you're creating / updating a post. If I just click a button (to add asterisks or brackets etc) and don't type anything, the value never gets updated in the content observable. I do have a save button that I

Sanitizing Input with JsonConvert.SerializeObject in MVC4?

僤鯓⒐⒋嵵緔 提交于 2019-12-22 08:59:10
问题 Long story short, I'm trying to get the output from JsonConvert.SerializeObject to be sanitized without having to modify the contents of the saved data. I'm working on an app that has the following markup in the view: <textarea data-bind="value: aboutMe"></textarea> If I save the following text, I run into problems: <script type="text/javascript">alert("hey")</script> The error I get in FF: The relevant part of the offending rendered text: $(document).ready(ko.applyBindings(new MyProfileVm({

KO Grid Display Isseues, On resize Gird shows one row. Images also included

戏子无情 提交于 2019-12-22 08:20:54
问题 Using the following. 1) Visual Studio 2012. 2) Hot towel template. 3) downloaded ko grid and and its css. home.html <section id="alerts-view" class="view"> <header> <a class="btn btn-info btn-force-refresh pull-right" data-bind="click: refresh" href="#"><i class="icon-refresh"></i> Refresh</a> <h3 class="page-title" data-bind="text: title"></h3> <div class="article-counter"> <address data-bind="text: alerts().length"></address> <address>found</address> </div> </header> <div data-bind="koGrid:

How do you observe JavaScript hashtables in Knockout?

半城伤御伤魂 提交于 2019-12-22 06:03:54
问题 In my Knockout viewmodel, I've got some properties where I'm trying to make a hash observable. So instead of my pre-Knockout code of self.MyHash = {}; I am now using: self.MyHash = ko.observable({}); In other parts of my code, I am manipulating the hash with statements like these: // add an entry self.MyHash()["test"] = "My Value"; // remove an entry delete self.MyHash()["test"]; The code works, in that the entries are added and removed properly. However, the changes to the hashtable don't

How do you observe JavaScript hashtables in Knockout?

风流意气都作罢 提交于 2019-12-22 06:03:07
问题 In my Knockout viewmodel, I've got some properties where I'm trying to make a hash observable. So instead of my pre-Knockout code of self.MyHash = {}; I am now using: self.MyHash = ko.observable({}); In other parts of my code, I am manipulating the hash with statements like these: // add an entry self.MyHash()["test"] = "My Value"; // remove an entry delete self.MyHash()["test"]; The code works, in that the entries are added and removed properly. However, the changes to the hashtable don't

Swipe action binding in knockoutjs

99封情书 提交于 2019-12-22 05:41:12
问题 I am using knockout as main framework in my application and it has to support tablets and mobile devices. As the framework is built on binding handlers I wonder how can custom binding to actions (like swipe and other device specific ones) be achieved, or maybe there is something like this done? 回答1: Probably too late, but here is a library that adds touch binding to knockoutjs: https://github.com/yaroslavya/knockouch 回答2: Create a bindingHandler . Here you go an example of a real project ko

Swipe action binding in knockoutjs

纵然是瞬间 提交于 2019-12-22 05:41:03
问题 I am using knockout as main framework in my application and it has to support tablets and mobile devices. As the framework is built on binding handlers I wonder how can custom binding to actions (like swipe and other device specific ones) be achieved, or maybe there is something like this done? 回答1: Probably too late, but here is a library that adds touch binding to knockoutjs: https://github.com/yaroslavya/knockouch 回答2: Create a bindingHandler . Here you go an example of a real project ko

Automatically refresh list view on change - knockoutjs & JQuery Mobile

别来无恙 提交于 2019-12-22 05:37:25
问题 I am using knockoutjs (very new to it) with JQuery Mobile. I have a listview which I bind filtered results to. After I load my data the first time I have to call $('ul').listview('refresh'); in order for JQM to restyle my list, this works great. However when I filter my list, it is rerendered and looses the style again and I can't figure out where to call the refresh again. My html is as follows: <p>Filter: <input data-bind="value: filter, valueUpdate: 'afterkeydown'" /></p> <ul data-role=

knockout.js applybindings after breeze js queries completed

徘徊边缘 提交于 2019-12-22 05:34:14
问题 The question: How can I structure my code so that the knockout bindings are not applied until all of the queries for the ViewModel have been executed? Update: After some further research and experimentation I think that using something along the lines of a Deferred function may work. I have tried a few implementations, however it only defers until the query is called, rather than until all query results have been processed. I'm obviously doing something wrong here but my javascript foo is

Are computed observables on prototypes feasible in KnockoutJS?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 05:25:12
问题 I have an array of items coming back from the service. I'm trying to define a computed observable for every Item instance, so my instinct tells me to put it on the prototype. One case for the computed observable: the system calculates points, but the user can choose to override the calculated value. I need to keep the calculated value available in case the user removes the override. I also need to coalesce user-assigned and calculated points, and add up the totals. I'm using mapping to do the