Git Product home page Git Product logo

Comments (13)

sagacity avatar sagacity commented on July 18, 2024

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.

sgentile avatar sgentile commented on July 18, 2024

Great - Thank you !

from knockout.mapping.

younes200 avatar younes200 commented on July 18, 2024

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.

sgentile avatar sgentile commented on July 18, 2024

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.

sgentile avatar sgentile commented on July 18, 2024

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.

younes200 avatar younes200 commented on July 18, 2024

Thank you, works fine !

from knockout.mapping.

Gooseus avatar Gooseus commented on July 18, 2024

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.

domenic avatar domenic commented on July 18, 2024

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.

Gooseus avatar Gooseus commented on July 18, 2024

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.

domenic avatar domenic commented on July 18, 2024

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.

Gooseus avatar Gooseus commented on July 18, 2024

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.

domenic avatar domenic commented on July 18, 2024

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.

Gooseus avatar Gooseus commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.