noveogroup / backbone.iobind

Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.
https://noveogroup.github.io/backbone.iobind/
582 stars 65 forks source link

Only the first part of URL is used for the namespace #50

Open gkorland opened 10 years ago

gkorland commented 10 years ago

In my case (and I it's very common when you have complex model) the url looks like this: /users/profiles/categories/{cat_id}

But Backbone.iosync only uses the first part as a namespace:

if (params.url) {
    params.url = _.result(params, 'url');
  } else {
    params.url = _.result(model, 'url') || urlError();
  }

  var cmd = params.url.split('/')
    , namespace = (cmd[0] !== '') ? cmd[0] : cmd[1]; // if leading slash, ignore

Which means all models which have a URL that starts with /users/... loose the rest of the URL.

mahnunchik commented 10 years ago

tests are broken

gkorland commented 10 years ago

how do you run the tests?

npm install
make test

Yells

 1) Backbone.iobind ioBind:
     TypeError: Object function ( w ) {
                if ( !w.document ) {
                    throw new Error( "jQuery requires a window with a document" );
                }
                return factory( w );
            } has no method 'Deferred'
mahnunchik commented 10 years ago

Definition of commonjs jquery module was changed in new version. This error is because of this.

I have just updated package.json in this repos with jquery 1.8.3 as dependency. With this fix these tests pass.

npm install
make build
make test

Tests do not pass because the new changes added model id to the destination url.

mahnunchik commented 10 years ago

@gkorland Could you please provide tests