knockout.js

Yii and Knockout Together? [closed]

霸气de小男生 提交于 2020-01-14 19:50:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am trying to decide on a set of tools to use for a new web app I am going to build. I want it to be really interactive and work

Knockout does not sync manual set of option's selected attribute

℡╲_俬逩灬. 提交于 2020-01-14 17:35:54
问题 I'm using this jQuery plugin for a multi select list box http://www.quasipartikel.at/multiselect/, and it's all bound to a view model using knockoutjs. The plugin sets the option's selected attribute when an item is selected or deselected. But knockout is obviously not checking for change in that attribute and so my view model is not being updated. Now before I change the plug in and write a custom binding is there a way to tell knockoutjs to monitor the selected attribute? 回答1: You can

select2 change ajax url

纵饮孤独 提交于 2020-01-14 14:03:33
问题 Im working with knockout.js and select2 plugin. Im trying to change the select2 ajax url based on a value of an observable. for example if based on some selection i do ajax call to 1 url or another. Here is a sample code: <input type="hidden" data-bind="combobox: { optionsText: 'Name', optionsValue: 'ID', optionsCaption: 'Избери...', sourceUrl: partnerUrl }, value: ApplyToSubject" id="ApplyToSubject" name="ApplyToSubject"> This is how the sourceUrl: partnerUrl is retrieved: self.partnerUrl =

knockout: Uncaught TypeError: Object #<Object> has no method 'newCommentText'

☆樱花仙子☆ 提交于 2020-01-14 10:42:18
问题 I have code like this in my view model: function ChatListViewModel(chats) { var self = this; self.newCommentText = ko.observable(); self.addComment = function(chat) { var newComment = { CourseItemDescription: this.newCommentText() }; chat.CommentList.push(newComment); self.newCommentText(""); }; } ko.applyBindings(new ChatListViewModel(initialData)); but I get this error when I try to add a new comment: any Ideas what I'm doing wrong? I looked at some knockout samples on the knockoutjs.com

KnockoutJS 2.3: 'custom binding' + 'ko.applyBindings to partial view' throws error

混江龙づ霸主 提交于 2020-01-14 03:13:08
问题 I've got some code that uses knockout.js, a custom binding and a calls applyBindings() to a partial view. jsfiddle with ko 2.2.1 var handle = slider.slider().find(".ui-slider-handle").first(); $(handle).attr("data-bind", "tooltip: viewModel.value"); ko.applyBindings(viewModel.value, $(handle)[0]); Now, with ko version 2.3, I get the error "You cannot apply bindings multiple times to the same element." jsfiddle with ko 2.3 I've probably always had this problem but previous versions of knockout

External templates and “el” with Knockout and RequireJS?

孤者浪人 提交于 2020-01-13 18:55:14
问题 I am trying to use Knockout ViewModels as self-contained "widgets" that can be placed into any (or multiple) DOM nodes on the page. I had an approach in Backbone that seemed to work well and I'm trying to convert the concept to Knockout. In Backbone view I would do something like this, using the RequireJS text plugin to pull the template and inject it into the el: define(['text!templates/myTemplate.html',], function(templateHTML){ var view = Backbone.View.extend({ initialize:function() { //

Knockout move observableArray item down

不打扰是莪最后的温柔 提交于 2020-01-13 15:03:47
问题 From this question, i know how to move an item up: moveUp: function(category) { var i = categories.indexOf(category); if (i >= 1) { var array = categories(); categories.splice(i-1, 2, array[i], array[i-1]); } } What is the equivalent for moving the item down? 回答1: In this solution, i delete two items, from index position, and then again insert them (first - the next item, and the second - moving item): moveDown = function(number) { var i = self.numbers().indexOf(number); if (i < self.numbers(

Is there an alternative to the IValueConverter in Knockout js?

左心房为你撑大大i 提交于 2020-01-13 07:06:08
问题 First of all, I know you can use Computed observables. They are really great for complex properties, but IMO are not a worthy replacement for the IValueConverters you have in Silverlight. In my current project, I have multiple datepickers. Right now, I have to create an extra computed observable for each date, because I want the formatting to work. So If I have 5 dates that's 10 properties, where in Silverlight you would have 5 dates and 1 generic dateconverter. It works, but it's not very

Is there an alternative to the IValueConverter in Knockout js?

若如初见. 提交于 2020-01-13 07:05:12
问题 First of all, I know you can use Computed observables. They are really great for complex properties, but IMO are not a worthy replacement for the IValueConverters you have in Silverlight. In my current project, I have multiple datepickers. Right now, I have to create an extra computed observable for each date, because I want the formatting to work. So If I have 5 dates that's 10 properties, where in Silverlight you would have 5 dates and 1 generic dateconverter. It works, but it's not very

Is there an alternative to the IValueConverter in Knockout js?

删除回忆录丶 提交于 2020-01-13 07:05:12
问题 First of all, I know you can use Computed observables. They are really great for complex properties, but IMO are not a worthy replacement for the IValueConverters you have in Silverlight. In my current project, I have multiple datepickers. Right now, I have to create an extra computed observable for each date, because I want the formatting to work. So If I have 5 dates that's 10 properties, where in Silverlight you would have 5 dates and 1 generic dateconverter. It works, but it's not very