我试图计算'observableArray'的'price'字段的总和.到目前为止,我有以下代码:
(function(){
function objFeatures(name,price) {
return {
name: ko.observable(name),
price: ko.observable(price),
removeFeatures: function () {
appViewModel.features.remove(this);
}
}
}
var appViewModel = {
features: ko.observableArray([
new objFeatures("Feature1", 20),
new objFeatures("Feature2", 20)
]),
grandTotal: ko.computed(function () {
var total = 0;
ko.utils.arrayForEach(this.features(), function () {
total += this.price();
})
return total;
})
};
ko.applyBindings(appViewModel);
}());
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我在firebug控制台中得到一个"错误:this.features不是函数".
我究竟做错了什么?
对于亚马逊服务(S3,EC2,SimpleDB的)所有操作您需要签署与HMAC-SHA-1签名(所有resquest http://en.wikipedia.org/wiki/HMAC,http://docs.amazonwebservices.com /AWSFWS/latest/DeveloperGuide/index.html?SummaryOfAuthentication.html).
我在asp.net后端工作,没有问题.问题出在iPhone应用程序中.iPhone开发人员说,没有办法使用HMAC-SHA-1编码,他也没有办法实现自己的算法.作为程序员,我无法理解为什么会出现问题.
所以我想知道iPhone开发者是对的吗?
我从来没有为iPhone编码,所以我甚至没有在哪里搜索这样的信息.
生产服务器上有很多麻烦.某些路由导致应用程序池崩溃,事件ID为1011:
事件类型:警告事件来源:W3SVC事件类别:无事件ID:1011日期:1/21/2009时间:9:08:17 AM用户:N/A计算机:xxxxxxxxxxxxx描述:
为应用程序池"DefaultAppPool"提供服务的进程与World Wide Web Publishing服务发生了致命的通信错误.进程ID为'3788'.数据字段包含错误编号.8007006d
在我发现问题之前,我有几个非常艰难的时间.感谢Tess Ferrandez和她的博客文章,我发现了它.
总是仔细检查asp.net应用程序中的多线程代码.当发生未处理的异常时,应用程序池崩溃,很难找到原因.
我有一个大问题.现场有设备发送URL"/ updates".这是这些设备开发人员的错字.在服务器日志中,它看起来像"/ updates +".
我有一个ManageURL重写模块,可以处理所有没有扩展名的请求.但是这个请求会导致HttpException:
System.Web.HttpException:
System.Web.HttpException
at System.Web.Util.FileUtil.CheckSuspiciousPhysicalPath(String physicalPath)
at System.Web.HttpContext.ValidatePath()
at System.Web.HttpApplication.ValidatePathExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Run Code Online (Sandbox Code Playgroud)
正如我在日志中看到的,URL重写模块甚至没有获取此URL,因此我无法在那里修复它.
有没有办法用ASP.NET处理这些URL?
使用Knockout 2.0使用此数据绑定:
data-bind="click: $root.deleteSomeEntity.bind($data, $parent)"
Run Code Online (Sandbox Code Playgroud)
在Knockout viewmodel JavaScript中的第一个参数
self.deleteSomeEntity = function (data, parent) {
// perform deletion
}
Run Code Online (Sandbox Code Playgroud)
似乎是父母而不是数据.
是否有这种行为的原因或我缺少的东西?
有没有办法使用PSAKE发布asp.net Web应用程序,就像visual studio一样?
寻找如何在knockoutjs中设置子模型的一个很好的例子.这包括绑定到儿童事件,例如我尚未能够正常工作的属性更新.
此外,在这种情况下绑定到单个子节点而不是数组会更好,但我不知道如何在没有foreach模板的情况下在html中设置它.
http://jsfiddle.net/mathewvance/mfYNq/
谢谢.
<div class="editor-row">
<label>Price</label>
<input name="Price" data-bind="value: price"/>
</div>
<div class="editor-row">
<label>Child</label>
<div data-bind="foreach: childObjects">
<div><input type="checkbox" data-bind="checked: yearRound" /> Year Round</div>
<div><input type="checkbox" data-bind="checked: fromNow" /> From Now</div>
<div>
<input data-bind="value: startDate" class="date-picker"/> to
<input data-bind="value: endDate" class="date-picker"/>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
var ChildModel= function (yearRound, fromNow, startDate, endDate) {
var self = this;
this.yearRound = ko.observable(yearRound);
this.fromNow = ko.observable(fromNow);
this.startDate = ko.observable(startDate);
this.endDate = ko.observable(endDate);
this.yearRound.subscribe = function (val) {
alert('message from child model property subscribe\n\nwhy …Run Code Online (Sandbox Code Playgroud) 如何操作dotnet核心中的控制台光标位置?
据我所知,在https://github.com/dotnet/corefx/blob/master/src/System.Console/src/System/Console.cs中,没有办法操纵光标位置.
这是否意味着它在Windows上是不可能的,并且可以通过ANSI转义序列在Linux上实现?
当我从服务器获取单个项目的新数据时,我正在遇到UI刷新问题,该项目位于包含多个可观察对象的包装对象的observableArray中.
考虑以下:
var vm = {
....
localEdited: ko.mapping.fromJS(new ItemWrapper(defaultModelSerialised)),
selected: ko.observable(null),
editItem: function(data) {
// clone a temporary copy of data for the dialog when opening (*.localEdited on dialog)
var clonedData = ko.toJS(data);
ko.mapping.fromJS(clonedData, null, this.localEdited);
// selected should now point to the item in the obserable array which will be refreshed
this.selected(data);
// open dialog...
},
submitDialog: function(data) {
// submit data to server...
// (1) commit the data back to UI (new item is return in resp.entity …Run Code Online (Sandbox Code Playgroud) 你如何管理ASP.NET 项目中的所有你的.js和.css文件?尤其是当他们彼此之间有很多依赖时?
我已将所有脚本合二为一。但它变得很重要,其中 90% 没有在特定页面上使用。我想要的是管理所有这些脚本的工具或指导,简单的依赖管理,有助于在页面上仅包含该页面需要的那些 JS 和 CSS。
当您使用大量控件时,还使用了 ScriptManager nut,它非常方便......也许我以错误的方式使用它。
我有一个项目集合,我想显示每个项目的总数和个别百分比.问题似乎是我在计算总数时需要父对象的引用.所以我想我会定义Collection的计算getTotal和项目的百分比.
function Collection() {
var self = this;
self.parts = ko.observableArray();
self.getTotal = ko.computed(function() {
var total = self.parts.length;
return total;
});
}
function Part(amount, parent) {
var self = this;
self.amount = ko.observable(amount);
self.parent = parent;
self.percentage = ko.computed(function() {
return self.amount() / self.parent.getTotal();
});
}
var partsData = [40, 50, 30];
var collection = new Collection();
for (var i = 0; i < partsData.length; ++i) {
collection.parts.push(new Part(partsData[i], collection));
}
ko.applyBindings(collection);
Run Code Online (Sandbox Code Playgroud)
我的HTML是
<ul data-bind="foreach: parts">
<li>
<p data-bind="text: …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个自定义线程池实用程序,但似乎有一个我找不到的问题.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
namespace iWallpaper.S3Uploader
{
public class QueueManager<T>
{
private readonly Queue queue = Queue.Synchronized(new Queue());
private readonly AutoResetEvent res = new AutoResetEvent(true);
private readonly AutoResetEvent res_thr = new AutoResetEvent(true);
private readonly Semaphore sem = new Semaphore(1, 4);
private readonly Thread thread;
private Action<T> DoWork;
private int Num_Of_Threads;
private QueueManager()
{
Num_Of_Threads = 0;
maxThread = 5;
thread = new Thread(Worker) {Name = "S3Uploader EventRegisterer"};
thread.Start();
// log.Info(String.Format("{0} [QUEUE] FileUploadQueueManager created", DateTime.Now.ToLongTimeString()));
} …Run Code Online (Sandbox Code Playgroud)