0

I'm searching for a way to use Parse JS SDK with Durandal. As Parse JS SDK is a Backbone module it seems to it should be somehow modified. I'm not familiar with Backbone and I can't find a guide which can help me with it. I want to use Parse Java Script SDK as common Durandal (more precisely require.js) module as following:

define(['knockout', 'gmaps', 'durandal/composition'], function (ko, gmaps, composition) {
...
var latLng = new gmaps.LatLng(blah blah);
...

I'm trying to use Parse SDK similarity but have no luck there:

define(['parse'], function(parse) {
console.log('Parse: ' + parse); //undefined

I added a path to it in my config:

requirejs.config({
    paths: {
        'text': '../lib/require/text',
        'async': '../lib/require/plugins/async',
        'propertyParser': '../lib/require/plugins/propertyParser',
        'goog': '../lib/require/plugins/goog',
        'durandal': '../lib/durandal/js',
        'plugins': '../lib/durandal/js/plugins',
        'transitions': '../lib/durandal/js/transitions',
        'bootstrap': '../lib/bootstrap/js/bootstrap',
        'knockout': '../lib/knockout/knockout-2.3.0',
        'parse': '../lib/parse/parse'
    }
});

Inside the SDK module there are really lot of code and I can't understand how it should be modified for further Durandal use. Someone could explain this?

P.S. I see that using the Parse JavaScript SDK is comfortable way to work with Parse BaaS, but if this SDK cannot be converted for my purposes, would not it be too hard to use Parse with pure JS ? I mean without SDK.

Thanks!

1
  • If you don't already use Backbone, I would recommend their REST API instead. Commented Jul 6, 2014 at 11:18

1 Answer 1

1

Your config seems ok, thou maybe the shim is missing. A quick search via google brought up this projects main.js config.

Here is the shim part:

parse: { deps: ['jquery', 'underscore'], exports: 'parse' }

Hope this helps in any way

EDIT: As mentioned in the comments it may be that Parse.com isn't AMD conform. Having googled a bit I found a (github project)[https://github.com/guillegette/amd-parse] which makes it AMD-conform. Guess this will help you out.

Sign up to request clarification or add additional context in comments.

3 Comments

just to make sure have you edited your config to include underscore as well? I guess this is needed since underscore.js is defined as dependency. So download it and add it to your paths.config
I added. I even added backbone and all other possible deps. That's strange but I found code that works for other people and trying to make the same but no luck. I updated all versions of my libraries but still no luck. It's probably to hard to make but can anyone provide an example on jsfiddle?
I see no easy way making a Fiddle of Durandal. Since you mentioned seeing others working with the setup I guess there must be a problem in your project itself. As a last solution, although not very nice, you could simply include Parse statically via script-src tag. Edit: maybe the library isn't AMD conform, means its not returning anything. Try simply adding a define(function(require) {} around the whole script in this case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.