KoLite 1.0.2

KoLite - Lightweight Toolkit for KnockoutJS

// asyncCommand
// -----------------------------

<button data-bind="command:
saveCommand">Save</button>



self.saveCommand = ko.asyncCommand({
   execute: function(callback) {
       $.ajax({
           complete: callback,
           data: { name: self.name() },
           type: 'POST',
           url: '/save/',
                   
           success: function(result) {
               alert('Name saved:' + result)
           }
       })
   },
       
   canExecute: function(isExecuting) {
       return !isExecuting && self.name()
   }
})


// asyncCommand and activity
// -----------------------------


<button data-bind="activity: saveCommand.isExecuting, command: saveCommand">Save</button>



// dirtyFlag
// -----------------------------


// Your model
var Person = function () {
   var self = this;
   self.id = ko.observable();
   self.firstName = ko.observable().extend({ required: true });
   self.lastName = ko.observable().extend({ required: true });
   self.dirtyFlag = new ko.DirtyFlag([self.firstName,self.lastName]);
   return self;
};


// Hook these into your viewmodel ...


//Property on your view model. myPerson is an instance of Person.
//Did it Change?
isDirty = ko.computed(function () {
   return myPerson().dirtyFlag().isDirty();
}),

//Resync Changes
dirtyFlag().reset();

There is a newer version of this package available.
See the version list below for details.
Install-Package KoLite -Version 1.0.2
dotnet add package KoLite --version 1.0.2
<PackageReference Include="KoLite" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KoLite --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 84,021 8/28/2014
1.1.0 74,152 12/21/2012
1.0.4 7,829 9/30/2012
1.0.3 1,699 8/13/2012
1.0.2 487 8/13/2012
1.0.1 532 8/13/2012
1.0.0 459 8/13/2012