maccman/spine — Issue #165: Remote Ajax Endpoint Setting Doesn't Work?
Author: yaru22
Created: 2011-12-24 17:23:00+00:00
State: open

According to http://spinejs.com/docs/ajax, I should be able to set the remote ajax endpoint by setting Spine.Model.host.
However, when AJAX request is made, it doesn't send the request to the remote host.

I created a model as follows:

```coffeescript
Spine = require('spine')

class TestModel extends Spine.Model
@configure 'TestModel'
@extend Spine.Model.Ajax
@url: "/testModel" # endpoint url for RESTful API

module.exports = TestModel
```

In public/index.html, I set Spine.Model.host = "http://localhost:3000" as follows:

```javascript
Spine.Model.host = "http://localhost:3000"
var jQuery = require("jqueryify");
var exports = this;
jQuery(function() {
var App = require("main");
exports.app = new App({el: $("body")});
});
```

In index.coffee, I tried to fetch TestModel as follows:

```coffeescript
require('lib/setup')

Spine = require('spine')
TestModel = require('models/TestModel')

class App extends Spine.Controller
constructor: ->
super
@log("Initialized")
TestModel.fetch()

module.exports = App
```

However, when I open a development console on my Chrome, it says "GET http://localhost:9294/testModel 404 (Not Found)"

Why would it send a request to localhost:9294 rather than the specified host localhost:3000 ?