- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目标
采用用户选择的测试组并过滤 Models.scenarios 以仅显示适用于用户选择的场景。一旦向用户显示正确的场景列表,他们就会选择自己的场景并开始测试。
最终结果我想要一个测试组(例如 1,2,3,4,5)和一个场景编号(1,2,3 等...)
我知道我应该使用 arrayFilter 和计算变量来实现此目的,但我的实现每次都会失败。
fiddle
http://jsfiddle.net/winsconsinfan/ffcudgrf/4/
查看
<p>Welcome to our Usability testing application.</p>
<p>
<label class="control-label">To which Test Group do you belong?</label> <em>Found in your invitation email.</em>
</p>
<label class="radio-inline">
<input type="radio" name="testGroupSelection" value="1" data-bind="checked: testGroupNumber">1</label>
<label class="radio-inline">
<input type="radio" name="testGroupSelection" value="2" data-bind="checked: testGroupNumber">2</label>
<label class="radio-inline">
<input type="radio" name="testGroupSelection" value="3" data-bind="checked: testGroupNumber">3</label>
<label class="radio-inline">
<input type="radio" name="testGroupSelection" value="4" data-bind="checked: testGroupNumber">4</label>
<label class="radio-inline">
<input type="radio" name="testGroupSelection" value="5" data-bind="checked: testGroupNumber">5</label>
<div data-bind="visible: testGroupNumber">
<p>You belong to Test Group <span data-bind="text: testGroupNumber"></span>
</p>
<p>And you'll be testing which scenario?</p>
<div data-bind="foreach: Models.scenarios">
<label data-bind="text: scenarioDescription">
<input type="radio" name="scenarioSelection" data-bind="checked: selectedScenario()" />
</label>
</div>
</div>
View 模型
var Models = window["Models"] = {};
(function () {
Models.ViewModel = function () {
var self = this;
self.testGroupNumber = ko.observable();
self.selectedScenario = ko.observable();
self.filteredScenarios = ko.computed(function () {
//code here
});
}
Models.scenarios = ko.observableArray([{
id: 's1q1',
testGroup: 1,
scenarioNumber: 1,
scenarioDescription: "It is nearing the end of the plan year for your Health Care FSA and you want to check your available balance. Find how much money you have left in your account."
}, {
id: 's1q2',
testGroup: 1,
scenarioNumber: 2,
scenarioDescription: "You can’t remember how much you elected for your Health Care FSA. Find how much you elected for the current plan year."
}, {
id: 's1q3',
testGroup: 1,
scenarioNumber: 3,
scenarioDescription: "You received a check in the mail from Employee Benefits Corporation and you don’t know why. Find where you can view an explanation."
}, {
id: 's1q4',
testGroup: 1,
scenarioNumber: 4,
scenarioDescription: "You want your spouse to have the ability to call and discuss your account on your behalf with Employee Benefits Corporation. You’ll have to fill out an authorization document to do this. Find where that is located."
}, {
id: 's1q5',
testGroup: 1,
scenarioNumber: 5,
scenarioDescription: "You need to purchase more parking passes so you can park your vehicle while at work. You would like to pay for these passes pre-tax. Find where you can place an order for parking passes."
}, {
id: 's2q1',
testGroup: 2,
scenarioNumber: 1,
scenarioDescription: "You discovered an old receipt in your basement and can’t remember if you already submitted a claim for the expense for your Health Care FSA. Find where you can view the claims you have submitted in the past. "
}, {
id: 's2q2',
testGroup: 2,
scenarioNumber: 2,
scenarioDescription: "You recently visited the doctor’s office and want to submit a claim to be reimbursed from your Health Care FSA account for the expense. Find where you can submit this information."
}, {
id: 's2q3',
testGroup: 2,
scenarioNumber: 3,
scenarioDescription: "You recently received a reimbursement check in the mail and are unsure which claims the payment is for. Find where you can view a breakdown of claims that make up the payment check."
}, {
id: 's2q4',
testGroup: 2,
scenarioNumber: 4,
scenarioDescription: "You have $100.00 left in your Health Care FSA account that you must use by the end of the year. You want to know what types of expenses you can submit to use up this money. Find what medical expenses you can submit for reimbursement."
}, {
id: 's2q5',
testGroup: 2,
scenarioNumber: 5,
scenarioDescription: "You are tired of having to pay your doctor’s bills yourself after you receive a check from Employee Benefits Corporation. You would prefer to have the reimbursements sent directly to your doctor’s office. Find where you can sign up for this service."
}, {
id: 's3q1',
testGroup: 3,
scenarioNumber: 1,
scenarioDescription: "You enrolled in the Simply HSA plan for the first time and need to check your account balance. Find where you can log in to HSA Bank."
}, {
id: 's3q2',
testGroup: 3,
scenarioNumber: 2,
scenarioDescription: "You recently moved into a new house and want to notify Employee Benefits Corporation of your new address so your reimbursement checks are sent to the correct place. Find where you can update your address."
}, {
id: 's3q3',
testGroup: 3,
scenarioNumber: 3,
scenarioDescription: "You can’t locate what you are looking for on the Employee Benefits Corporation menu and would like to call customer service. Find Employee Benefits Corporation’s phone number."
}, {
id: 's3q4',
testGroup: 3,
scenarioNumber: 4,
scenarioDescription: "You recently swiped your Benny Benefits Card at your dentist’s office and were notified by Employee Benefits Corporation that you must submit documentation in order to be reimbursed from your Health Care FSA account for the expense. Find where you can submit this information."
}, {
id: 's3q5',
testGroup: 3,
scenarioNumber: 5,
scenarioDescription: "You want more details on services that Employee Benefits Corporation offers. Find where you can view flyers and brochures."
}, {
id: 's4q1',
testGroup: 4,
scenarioNumber: 1,
scenarioDescription: "This is the first time you have participated in the EBC HRA Plan. Find how much you are responsible for paying out of pocket. "
}, {
id: 's4q2',
testGroup: 4,
scenarioNumber: 2,
scenarioDescription: "You recently had your identify stolen and want to update your user name and password as a precaution. Find where you can do this."
}, {
id: 's4q3',
testGroup: 4,
scenarioNumber: 3,
scenarioDescription: "You are tired of receiving paper checks in the mail and would like your reimbursements to be deposited directly into your bank account. Find where you can sign up for this service."
}, {
id: 's4q4',
testGroup: 4,
scenarioNumber: 4,
scenarioDescription: "You are having issues using your Benny Benefits Card at the pharmacy and you wonder what’s wrong with your card. Find your card status."
}, {
id: 's5q1',
testGroup: 5,
scenarioNumber: 1,
scenarioDescription: "You recently received a reimbursement check for a claim that you submitted. The amount of the check is not what you expected. Find where you can view an explanation of why you didn’t receive a full payment."
}, {
id: 's5q2',
testGroup: 5,
scenarioNumber: 2,
scenarioDescription: "You recently got a new email address and want to make sure that all communication from Employee Benefits Corporation is sent via email. Find where you can update this information."
}, {
id: 's5q3',
testGroup: 5,
scenarioNumber: 3,
scenarioDescription: "You submitted a claim to Employee Benefits Corporation yesterday and want to know when you will be reimbursed. Find when you can expect a reimbursement check to be issued."
}, {
id: 's5q4',
testGroup: 5,
scenarioNumber: 4,
scenarioDescription: "You have been notified by your employer that it is time to enroll in the upcoming year’s flexible spending account plan. Find where you can make a new election."
}, {
id: 's5q5',
testGroup: 5,
scenarioNumber: 5,
scenarioDescription: "You received a letter from Employee Benefits Corporation explaining that the documentation you submitted with your last claim was illegible. Find where you can provide a new copy of the documentation for the claim."
}, ]);
})();
var myViewModel = new Models.ViewModel();
ko.applyBindings(myViewModel);
最佳答案
过滤!试试这个:
self.filteredScenarios = ko.computed(function () {
return Models.scenarios().filter(function (i) {
return i.testGroup == self.testGroupNumber();
});
});
检查working fiddle .
关于javascript - Knockout - 基于单选按钮选择的过滤器数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25555860/
我有一个对象数组,我想在键传入“filter”过滤器时提取值。下面是我尝试过的 Controller 代码片段,但我得到的响应类型未定义。请帮我找出哪里出错了。 var states = [{"HI
如果任何 J2EE 应用程序直接访问 servlet,然后 servlet 将相同的请求转发到某个 .jsp 页面。 request.getRequestDispatcher("Login.jsp")
我有一个带有图像缩略图的表单,可以通过复选框进行选择以进行下载。我想要一个包含 jQuery 中图像的数组,用于 Ajax 调用。 2个问题: - 表格顶部有一个复选框,用于切换我想要从映射中排除的所
我必须从服务器转储数据库,将 .sql 传输到另一台服务器,然后运行以下脚本以使用此语法删除某些行: DELETE wp_posts FROM wp_posts INNER JOIN wp_postm
我想从目录中过滤掉特定类型的文件,但收到错误“ token 语法错误,删除这些 token ”: File dir = new File("c:/etc/etc"); File[] f
几乎所有的 Web 应用程序都依赖外部的输入。这些数据通常来自用户或其他应用程序(比如 web 服务)。通过使用过滤器,您能够确保应用程序获得正确的输入类型。 您应该始终对外部数据进行过滤! 输
我正在开发一个由 OData 服务提供支持的搜索功能。它将返回一个或一列标题对象作为结果。我们需要搜索的许多字段不在标题对象中。它们仅在子对象(导航属性)中。能够针对子字段执行 OData 搜索并仍然
假设我有以下模型,它有一个方法 variants(): class Example(models.Model): text = models.CharField(max_length=255)
我有一个默认的列表列表,但我基本上想这样做: myDefaultDict = filter(lambda k: len(k)>1, myDefaultDict) 除了它似乎只适用于列表。我能做什么?
我正在使用 django-filter 来输出我的模型的过滤结果。那里没有问题。下一步是添加一个分页器……尽管现在已经苦苦挣扎了好几天。 views.py: def funds_overview(re
我正在做一个概念证明,我正在试验一种奇怪的行为。 我有一个按日期字段按范围分区的表,如果我设置固定日期或由 SYSDATE 创建的日期,查询的成本会发生很大变化。 这些是解释计划: SQL> SELE
如果一个或另一个值匹配,是否可以制作一个过滤器,例如一个中性的 PropertyFilter(并传递给链中的下一个过滤器)?就像是: value1 val
我是 VBA 初学者,正在尝试根据单元格值过滤数据,经过一番谷歌搜索后,我编写了一个有效的代码 Sub FilterDepartment_Sales() Sheet6.Activate
假设我在 excel 数据透视表中有两个过滤器。 两者最初都会显示筛选列的选定范围内的所有值。 当我仅在过滤器 1 中选择几个值时,过滤器 2 仍会继续显示基础数据中所选范围内特定过滤器列中的所有值。
是否可以定义自定义 build-ins (名称不再适合)在 ftl? 由于语义前提,我不想让它成为一个函数,而是一个内置的。 最佳答案 这是不可能的,?语法是为内置函数保留的。 (顺便说一句,这意味着
我试图在 Edit | 之外添加一个链接通过插件删除wordpress管理员>用户>所有用户列表中的链接..这是我第一次尝试通过查看其他插件或搜索google来制作wordpress插件.. 我添加了
我正在尝试按照以下教程使用 django 过滤器进行分页,但该教程似乎缺少某些内容,而且我无法使用基于函数的 View 方法显示分页。 https://simpleisbetterthancomple
由于我是 Powershell 新手,因此寻求最佳实践方面的帮助, 我有一个 csv 文件,我想过滤掉 csv 中的每一行,除了包含“未安装”的行 然后,我想根据包含计算机列表的单独 csv 文件过滤
我正在尝试创建一个搜索查询,它会告诉我我作为审阅者添加到其中的打开更改,但我还没有提交最新补丁集的代码审查。这应该包括其他人已经评论过的更改,但我没有。 我能找到的最接近的是 is:reviewer
在我的 Web 应用程序中,我有 3 个主要部分 1. 客户 2. 供应商 3. 管理员 我正在使用 java session 过滤器来检查用户 session 并允许访问网站的特定部分。 因此客户只
我是一名优秀的程序员,十分优秀!