knockout.js

connecting list view in knockout.js with map markers

徘徊边缘 提交于 2019-12-25 04:35:18
问题 I've been trying to connect the list view i have within a foreach data bind through knockout with my google map markers, i have tried. //Click on item in list view self.listViewClick = function(list) { if (this.name) { map.setZoom(15); map.panTo(this.latlng); list.setAnimation(google.maps.Animation.BOUNCE); } }; I tried changing out the "list" argument with self, this, and marker. I can only get the last map marker to bounce when i click on it in the list view when its set to marker. I know i

how to search with knockout

微笑、不失礼 提交于 2019-12-25 04:24:47
问题 i am trying to make a very simple search using knockout in a Durandal project. Demo in Jsfiddle What am i doing wrong here? Is there a better way to implement search ? var url = "https://www.googleapis.com/books/v1/volumes?q=the+Cat+In+The+Hat"; $.getJSON(url, function (data) { console.log(data.items); var books = data.items; var viewModel = { query: ko.observable('') }; viewModel.model = ko.mapping.fromJS(data.items); viewModel.books = ko.dependentObservable(function() { var search = this

Knockout js for attribute binding in IE8

☆樱花仙子☆ 提交于 2019-12-25 04:22:10
问题 Can't bind for attribute in IE8 http://jsfiddle.net/k2Mq7/ - ko 2.1: SCRIPT5022: Unable to parse bindings. Message: SyntaxError: Expected identifier, string or number; Bindings value: attr: { id: 'that-works', for: 'but-than-not' } http://jsfiddle.net/k2Mq7/3/ - ko 2.1 quoted for ('for'): jsfiddle fails but on my local machine no any errors but this label displayed without for attribute. Is it Knockoutjs bug or that I am doing something wrong? 回答1: Use quotation marks for attributes names

Knockout js for attribute binding in IE8

孤人 提交于 2019-12-25 04:22:01
问题 Can't bind for attribute in IE8 http://jsfiddle.net/k2Mq7/ - ko 2.1: SCRIPT5022: Unable to parse bindings. Message: SyntaxError: Expected identifier, string or number; Bindings value: attr: { id: 'that-works', for: 'but-than-not' } http://jsfiddle.net/k2Mq7/3/ - ko 2.1 quoted for ('for'): jsfiddle fails but on my local machine no any errors but this label displayed without for attribute. Is it Knockoutjs bug or that I am doing something wrong? 回答1: Use quotation marks for attributes names

Populating a dropdown list using knockout and jquery ajax

早过忘川 提交于 2019-12-25 04:11:37
问题 I am populating a drop down list using ajax like so. var getCertifications = function () { $.getJSON("/Provider/GetCertifications", function (data) { $.each(data, function (i, item) { var certification_data = "<option value=" + item.CertificationID + ">" + item.Certification + "</option>"; $(certification_data).appendTo("#certification"); }); }); }; getCertifications is being called in the document.ready method. I wanted to populate a second drop downlist based on the value of the selected

Populating a dropdown list using knockout and jquery ajax

[亡魂溺海] 提交于 2019-12-25 04:10:57
问题 I am populating a drop down list using ajax like so. var getCertifications = function () { $.getJSON("/Provider/GetCertifications", function (data) { $.each(data, function (i, item) { var certification_data = "<option value=" + item.CertificationID + ">" + item.Certification + "</option>"; $(certification_data).appendTo("#certification"); }); }); }; getCertifications is being called in the document.ready method. I wanted to populate a second drop downlist based on the value of the selected

A Button To Add A Product To A Cart

左心房为你撑大大i 提交于 2019-12-25 04:06:43
问题 My Shopping Cart Is Here http://jsfiddle.net/bkw5p/48/ in that i would like to show a button to user on products for adding that product to the shopping cart. Eg : when a button is clicked on a product it should add to cart instead of dragging to the cart i need a button to add that product to the cart i have tried it but i am unable to get it. kindly help to solve this issues as soon as possible thanks and regards s.varun 回答1: try this solution is below use the blow code and try it <a data

Loading a partial view in ASP.NET MVC using javascript

跟風遠走 提交于 2019-12-25 03:45:13
问题 I have about 15 partial views that I need to display based upon user's menu tab selection. Basically I have these 15 menu tabs on the side and based on user click for these tabs, I will be displaying the content for that tab on the page. Also I am using Knockout here. So I have these 15 Knockout observables ( self.tab_A(), self.tab_B(), ...self.tab_N() ) populated when the page first loads. The code I have is something like this. Here is the view. <ul id="tabs"> <li> <a data-bind="click:

UniqueID binding in knockout

雨燕双飞 提交于 2019-12-25 03:30:28
问题 I'm trying to figure out how to duplicate the functionality of the Unique Name binding for an element's ID (to get pretty validation working) ko.bindingHandlers.uniqueID = { 'init': function (element, valueAccessor) { if (valueAccessor()) { element.ID = "ko_unique_" + (++ko.bindingHandlers['uniqueName'].currentIndex); } } }; 回答1: The knockout source for uniqueName is ko.bindingHandlers['uniqueName'] = { 'init': function (element, valueAccessor) { if (valueAccessor()) { element.name = "ko

How to call a function again and again using knockout

五迷三道 提交于 2019-12-25 03:15:48
问题 I have this knockout code. self.newPatient = ko.asyncCommand({ execute: function(complete) { var isValid=$('#addPatientForm').parsley( 'validate' ); if(isValid){ var patientJson=ko.toJSON(self.patient()); formdata.append("json",patientJson); //self.enableButton(false); var imagepath= $.ajax({ url: projectUrl+"newPatient", type: "POST", data: formdata, processData: false, contentType: false, success: function (res) { formdata = new FormData(); imagepath=res; var length=self.patients().length;