Comments (13)
Hi Steve, Domenic Denicola just provided us with a module wrapper. It's now part of the master branch, maybe you can take a look and see if it already meets your needs?
from knockout.mapping.
Great - Thank you !
from knockout.mapping.
Hi, Is there a example to how to use knockout and knockout.mapping with requiresjs ? Here the code I'm using but with no luck :
define([ "order!jQuery"
, "order!libs/knockout/knockout"
, "order!libs/knockout/knockout.mapping"
]
, function() {
return ko;
}
);
I'm getting : Load timeout for modules: knockout http://requirejs.org/docs/errors.html#timeout
Thank you
from knockout.mapping.
the latest branch has native support for RequireJS - as well as the latest mapping - so you don't need the 'order' plugin
from knockout.mapping.
require({
paths: {
jqueryvalidate: 'libs/jquery/jquery.validate',
jqueryui: 'libs/jquery/jquery-ui-1.8.11.min',
bootstrap: 'libs/jquery/bootstrap',
knockout: 'libs/knockout/knockout-latest.debug',
komapping: 'libs/knockout/knockout.mapping-latest.debug',
}
}, ['csmain'], function ($) {
});
in 'main' then something like this:
define(['jquery', 'knockout', 'komapping'], function($, ko, komapping) {
...
}
from knockout.mapping.
Thank you, works fine !
from knockout.mapping.
You guys don't seem to be using the order plugin to load knockout before knockout.mapping, how are you handling the dependency? I'm trying to get them working together and am getting "ko is null" when knockout.mapping is loaded
require(['jquery', 'jquery.form', 'jquery.colorbox.min', 'jquery.tmpl.min', 'jquery.easing.1.3', 'jquery.bxSlider.min', 'knockout', 'knockout.mapping.debug', 'q.min', 'js/humane.min.js'],
function($,ko,komap,q) {
// Never get's here - 'ko is null on line 16'
console.log([$,ko,komap,q,window.humane]);
});
from knockout.mapping.
Your module ID <-> parameter map seems incorrect. You'd have to fix it like so:
require(['jquery',
'jquery.form',
'jquery.colorbox.min',
'jquery.tmpl.min',
'jquery.easing.1.3',
'jquery.bxSlider.min',
'knockout',
'knockout.mapping.debug',
'q.min',
'js/humane.min.js'],
function($, jQueryForm, jQueryColorBox, jQueryTmpl, jQueryEasing, jQueryBxSlider, ko, komap, q) {
console.log([$,ko,komap,q,window.humane]);
});
or like so (my preferred approach, if you can switch to define
instead of require
):
define(['jquery',
'jquery.form',
'jquery.colorbox.min',
'jquery.tmpl.min',
'jquery.easing.1.3',
'jquery.bxSlider.min',
'knockout',
'knockout.mapping.debug',
'q.min',
'js/humane.min.js'],
function(require) {
var $ = require("jquery");
var ko = require("knockout");
var komap = require("knockout.mapping.debug");
var q = require("q.min");
console.log([$,ko,komap,q,window.humane]);
});
from knockout.mapping.
I forgot to mention that I'm using the require-jquery.js from here:
http://requirejs.org/docs/jquery.html
So I shouldn't need to specify the jquery plugins separately in the arguments, other than that I don't see a difference between your first example and mine? I'll give your second approach a shot, though I'm getting the error in the ko.mapping so my callback doesn't even run.
from knockout.mapping.
There is a one-to-one mapping between elements of the array and arguments to the callback. So in your example, ko
(the second argument) is getting the exports from jquery.form
(the second element of the array), which are null
.
from knockout.mapping.
I simplified it to remove all the other modules and made sure they're ordered correctly:
require(['jquery', 'knockout', 'knockout.mapping.debug'],
function($,ko,komap) {
console.log([$,ko,komap]);
});
I'm still getting the same 'ko is null' error in knockout.mapping.debug
from knockout.mapping.
And you have the latest Knockout/Knockout Mapping?
https://raw.github.com/SteveSanderson/knockout/master/build/output/knockout-latest.debug.js
https://raw.github.com/SteveSanderson/knockout.mapping/master/build/output/knockout.mapping-latest.debug.js
from knockout.mapping.
Ah, looks like not... I had been using version 2.0.0 for knockout and saw a define function the source and a pull request for RequireJS support in 1.3.1 so I thought I was good.
Thank you sir for prompt assistance, I seem to be in business!
from knockout.mapping.
Related Issues (20)
- mapping fails if value = "constructor" HOT 2
- Is there a way to update the nested properties of the items of an ObservableArray? HOT 1
- Method visitPropertiesOrArrayEntries is doing unnecessary iterations on updateViewModel because the wrong variable is being used to check against ignored properties.
- Mapping not saved when data is an array HOT 1
- Mapping doesn't work when properties listed in different order HOT 4
- Empty observe array in mapping options creates observables from all properties HOT 1
- ko.mapping.toJSON to implement JSON formatting param like ko.toJSON
- Calling fromJS to amend an existing model with an ObservableArray fails
- NuGet package install directory
- Questions about Knockout Mapping HOT 10
- The "create" handler does not work with non-array properties HOT 1
- Create handler causes mapping to evaluate pureComputed HOT 1
- Suggestion: Safely update mapping when property in new object happens to be null
- mapping partial model into existing viewModel
- [Question] is arrayChanged part of the public api?
- objectLookup() + "watch" + Firefox = hilarity
- bug of optimizedKeys
- optionsCaption causes bound "value" to be deleted
- Doesn't seem to work with KO 3.4.2 HOT 1
- Having redudant data passed to an object makes it so the second reference of the same object is not updated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knockout.mapping.