jQWidgets Forums

jQuery UI Widgets Forums General Discussions jqxKnockout does not appear to work with requirejs

This topic contains 3 replies, has 3 voices, and was last updated by  fbar 12 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • martin
    Member

    We’re using the commercially licensed jqwidgets toolkit and we have been able to integrate knockout and jqxknockout with simple examples without a problem. However when we integrate this into our stack using requirejs the components does not appear to work. Actually, the component is not displayed and we do not get an error neither.

    We appreciate your help and prompt reply.

    Thanks!


    Peter Stoev
    Keymaster

    Hi,

    jqxknockout is expected to be loaded after the KO library and the widgets are expected to be initialized in the jQuery’s document.ready function. If any of that is not the problem on your side, then please send a sample to support@jqwidgets.com.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    martin
    Member

    This is exactly the problem. We’ve just sent an email to support but we’re going to send another one inlcuding a sample app with this issue.


    fbar
    Member

    I’ve experienced the same issue.
    The problem is that “jqxknockout.js” takes the “ko” dependency from window. While using requirejs knockout “ko” entry point is not exposed into the window object.

    A quick solution is to re-expose the knockout into the window object.

    File “jqx-ko-requirejs.js”:

    define(['knockout'], function (ko) {
    'use strict';
    var root = ( typeof window === 'object' && window ) || this;
    root.ko = ko;
    });

    Usage example:

    require.config({
    baseUrl : "libs",
    paths : {
    "jquery": ["//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery",
    "jquery-1.9.1"],
    "knockout": ["//ajax.aspnetcdn.com/ajax/knockout/knockout-2.2.1",
    "knockout-2.2.1"],
    "jqxwidgets": ["jqwidgets/jqx-all"],
    },
    shim: {
    "knockout": ["jquery"],
    "jqxwidgets": ["jquery", "knockout", "jqx-ko-requirejs"]
    }
    });
    require(['jquery', 'knockout'], function($, ko) {
    require(['jqx-ko-requirejs', 'jqxwidgets'], function() {
    //TODO...
    });
    });

    I hope the next release of jQWidgets will correct this issue and it will be more AMD “compilant”

    Regards,

    Francesc BAETA

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.