knockout-mvc

Display text when button clicked

独自空忆成欢 提交于 2020-01-05 08:13:29
问题 Creating my first ASP.NET MVC Knockout MVC. I've added a model setting 3 dates. The controller assigns 3 dates. Then they are displayed on screen using the view: <p>First Date: @ko.Html.TextBox(m => m.FirstDate)</p> <p>Second Date: @ko.Html.TextBox(m => m.SecondDate)</p> <p>Third Date: @ko.Html.TextBox(m => m.ThirdDate)</p> @ko.Apply(Model) The @ko.Apply(Model) being the main part which displays the 3 dates. I am trying to only show the 3 dates when a button is clicked, so iv put the code

Display text when button clicked

夙愿已清 提交于 2020-01-05 08:13:06
问题 Creating my first ASP.NET MVC Knockout MVC. I've added a model setting 3 dates. The controller assigns 3 dates. Then they are displayed on screen using the view: <p>First Date: @ko.Html.TextBox(m => m.FirstDate)</p> <p>Second Date: @ko.Html.TextBox(m => m.SecondDate)</p> <p>Third Date: @ko.Html.TextBox(m => m.ThirdDate)</p> @ko.Apply(Model) The @ko.Apply(Model) being the main part which displays the 3 dates. I am trying to only show the 3 dates when a button is clicked, so iv put the code

Knockout value not being set in function

 ̄綄美尐妖づ 提交于 2019-12-25 07:55:55
问题 I am having a problem when trying to get self.material (an observable) to load a value from within a function. When trying to load the observable in the select with a value, it shows as undefined. data.materialNumber has a string value and self.materials loads correctly. Any help would be appreciated! I'll try to include only the code needed... My html: <select class="materialSelect" data-placeholder="Choose Material..." data-bind="options: materials, value: material, optionsText: function

Not able to trigger Knockout data-bind using jQuery

喜你入骨 提交于 2019-12-24 14:04:00
问题 I am writing a plugin using jQuery and knockout. I have two radio buttons. I am using knockout data-bind to check and uncheck the radio button. The problem is that when I am trying to uncheck the radio button on click of another button using jQuery, it is not updating bind observable property . <input type="radio" data-bind="checked: selectedVal" name="1" value="fixedPrice"/> Fixed Price <input class="hn" type="radio" data-bind="checked: selectedVal" name="1" value="allowBiding"/> Allow

using a conditional on a knockout binded value

半腔热情 提交于 2019-12-24 09:17:45
问题 so i am using knockout to bind some set of values to a grid, using the foreach something like i have below. <table id="pcc-batch-list" class="table table-striped" > <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> </tr> </thead> <tbody data-bind="foreach:stuff"> <tr> <td data-bind="text: Something1"></td> <td data-bind="text: Something2"></td> <td data-bind="text: Something3"></td> <td data-bind="text: Something4"></td> </tr> </tbody> </table> and I want to

Knockout validation error in Internet Explorer?

不问归期 提交于 2019-12-23 23:25:50
问题 In my razor view that using knockout and supposedly knockout validation I add the following line (to actually start using ko validation): <script src="@Url.Content("~/Scripts/knockout.validation.debug.js")" type="text/javascript"></script> When I run this view in Chrome validation is working perfectly. When I run this view in IE (9.0), I get pretty ugly message saying the following: 0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'rules': object is null or

Bind data with nested object using Knockout MVC in MVC 4

本秂侑毒 提交于 2019-12-13 03:44:28
问题 I'm using Knockout MVC from here to integrate knockout to my website, but I have a problem. If my model contains another object, the binding will be unsuccessful. For example, here is my model: public class HelloWorldModel { public string FirstName { get; set; } public string LastName { get; set; } [Computed] public string FullName { get { return FirstName + " " + LastName; } } public ProductModel ProductModel { get; set; } } And here is my ProductModel public class ProductModel { public int

How to can I create an array of knockout.js observables?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 04:18:11
问题 I have an array of objects for which I am showing their properties. How can add an individual edit functionality to them? Lets say it to be an edit button for each one of the elements of the list. I want to show input fields instead of text fields when the object is in edit mode, for this I am using the visible binding. So I need a Boolean observable for each of them. How can I do this without knowing the amount of elements in the list... I also have add and delete, so I would need to add

Translate knockout into razor to keep it's validation working

元气小坏坏 提交于 2019-12-12 03:55:33
问题 Here is the problem that I am facing and not sure how to even approach it: I created models, controllers and views in ASP.NET MVC 4. At one point I had to create dynamic lists, so I opted out to KnockoutJS, what solves this problem extremely easy. So far so good. Then I realized that the validation I defined on my MVC models using I use Fluent Validation doesn't work anymore in the knockout view. I searched through SO and found few viable solutions: knockout validation jquery validation

how to detect a mouse click, enter key or tabbed item on drop down list box in knockout

[亡魂溺海] 提交于 2019-12-10 22:33:13
问题 What is the best way to get the selected item value from a dropdown list box when the user does one of the following; hits the tab key on the item, presses the enter key or mouse clicks the item. Do I have to create a javascript event handler for each event or is there a good way to do it with knockout. Are there any good jsfiddle examples I could look at? thanks 回答1: You could use a custom binding that catches those events. ko.bindingHandlers.tabEnterClick = { init: function(element,