knockout.js

Scroll to top of Bootstrap modal popup

谁说我不能喝 提交于 2020-01-04 14:11:53
问题 Below indicated is my HTML code, its a Bootstrap modal popup. What I am trying to do is if user clicks on save button, I am doing some sort of validation and if the validation fails, the message is displayed and should automatically scroll up to the top of the modal popup. but its not scrolling up. Below I have also indicated my code from JS file. <div id="addD" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="addPatientLabel" aria-hidden="true"> <div class="modal-header">

$parentContext.$index is not defined in Knockout.js

。_饼干妹妹 提交于 2020-01-04 14:03:28
问题 I am looping through the data and trying to create runtime html I am unable to fetch the index from the collection, I m using knockout-2.1.0.js. Am I doing something wrong? <ul data-bind="foreach: gridOptions.columns"> <li> <label data-role="none" data-bind="attr:{for: 'chk' + $parentContext.$index }"> </label> <input type="checkbox" data-bind="attr:{ id: 'chk' + $parentContext.$index }, checked: checked}" /><span data-bind="text:header"></span> </li> </ul> Viewmodel is gridOptions: { columns

Render partial view using knockout.js

三世轮回 提交于 2020-01-04 13:09:23
问题 I have a requirement to load tabs based on user selection in Asp.Net MVC4. Each tab element pertains to a partial view. Each partial view has its own knockout.js bindings. On click of each tab, partial view needs to be rendered below the previously selected tab. Here is a code snippet <div class="row-fluid top-pad-double" id="tabBasedGrowthDiv"> <ul class="nav nav-pills"> <li><a href="#tabCustomerInfo" data-toggle="tab" data-bind="click:$root.AddTab">CustomerInfo</a></li> <li><a href="

Colorize knockoutjs comment bindings in code editor

跟風遠走 提交于 2020-01-04 12:46:30
问题 A project I'm working on makes extensive use of knockout comment bindings. In the code editor, these are difficult to summarily differentiate from standard comments in the markup. Is there any way that one might be able to make knockout comment bindings appear in a different color? 回答1: In the absence of a solution, I coded an editor classifier Visual Studio extension to change the color of knockoutjs comment bindings in documents with HTML content types: https://github.com/biggyspender

Colorize knockoutjs comment bindings in code editor

China☆狼群 提交于 2020-01-04 12:46:13
问题 A project I'm working on makes extensive use of knockout comment bindings. In the code editor, these are difficult to summarily differentiate from standard comments in the markup. Is there any way that one might be able to make knockout comment bindings appear in a different color? 回答1: In the absence of a solution, I coded an editor classifier Visual Studio extension to change the color of knockoutjs comment bindings in documents with HTML content types: https://github.com/biggyspender

Asp MVC 3 json complex object not initialize properties

北战南征 提交于 2020-01-04 09:04:38
问题 I have next JS code where I call controller method SaveSettings: function SaveSettings() { // get json object from knockoutjs object var data = ko.toJSON(viewModel); var params = JSON.stringify(data); $.ajax({ url: '/MyAjax/SaveSettings/', type: "POST", data: JSON.stringify(data), dataType: "JSON", contentType: "application/json; charset=UTF-8", success: function (result) { alert('ok'); } }); } JSON Data have next format and sending to controller: { "Name":"xcvxcvxcv", "GeneralSetting": {

Knockout validation message based set in the validation function

て烟熏妆下的殇ゞ 提交于 2020-01-04 08:23:07
问题 I want to set the message to display in the validation function of knockout similar to whats going on here: Knockout Validation Plugin Custom Error Message but without async. Heres what ive tried, but no validation message is displayed. this.name = ko.observable().extend({ validation: { validator: function (val) { return { isValid:val === 'a', message: 'the value ' + val + ' is not a' }; }, message: 'I dont want this default message' } }); JSFiddle is there a good way to do this? 回答1: close,

Knockout .js with jQuery UI slider

三世轮回 提交于 2020-01-04 07:03:06
问题 Say I have the following jQuery UI sliders that are linked to a textbox. Is it possible to allow the user to enter values in the textbox that are greater than the sliders value (and set the slider to max)? ko.bindingHandlers.slider = { init: function (element, valueAccessor, allBindingsAccessor) { var options = allBindingsAccessor().sliderOptions || {}; $(element).slider(options); ko.utils.registerEventHandler(element, "slidechange", function (event, ui) { var observable = valueAccessor();

Form Data not serialized in asp.net core mvc controller model

情到浓时终转凉″ 提交于 2020-01-04 05:57:34
问题 C# model class public class SubCategoryTwoViewModel { public long Id { get; set; } public string SubCatTwoName { get; set; } public CategoryViewModel Category { get; set; } public SubCategoryOneViewModel SubCatOne { get; set; } public string PictureUrl { get; set; } public List<IFormFile> File { get; set; } public UserViewModel AddedBy { get; set; } public DateTime AddedOn { get; set; } public UserViewModel Updated_By { get; set; } public DateTime? UpdatedOn { get; set; } public bool Active {

Form Data not serialized in asp.net core mvc controller model

送分小仙女□ 提交于 2020-01-04 05:57:12
问题 C# model class public class SubCategoryTwoViewModel { public long Id { get; set; } public string SubCatTwoName { get; set; } public CategoryViewModel Category { get; set; } public SubCategoryOneViewModel SubCatOne { get; set; } public string PictureUrl { get; set; } public List<IFormFile> File { get; set; } public UserViewModel AddedBy { get; set; } public DateTime AddedOn { get; set; } public UserViewModel Updated_By { get; set; } public DateTime? UpdatedOn { get; set; } public bool Active {