Coder Social home page Coder Social logo

ember-rest's People

Contributors

dgeb avatar entea avatar jeremymarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-rest's Issues

Property binding on Model object does not work

For example:

App.User = Ember.Resource.extend({
resourceUrl: '/users',
resourceName: 'user',
resourceProperties: ['name', 'selected']
});

App.UserController = Ember.ResourceController.extend({

selecteds: function(){
    var users = this.get('content');
    return users.filterProperty('selected', true);
}.property('[email protected]')

})

As the propery 'selected' is not prepared for Ember when initializing the observer, the property binding on '[email protected]' won't work any more.
To fix the problem, you should declared the property you wanna binding explicitly, such as:

App.User = Ember.Resource.extend({
resourceUrl: '/users',
resourceName: 'user',
resourceProperties: ['name', 'selected'],
selected: false
});

I suggest the author to add this trick on the README.md, since l think lots of people will encounter this issue.

ember-rest has no bpm package

hey there

i'm new to ember and setup a very simple site using ember-rest and was pleasantly surprised when (with the help of the rack-cors gem) i was able to build a simple ember.js app that pulled data from site1 (rails) and displayed it on site2 (ember).

Great work.

I've just started filling out the app and wanted to move to a package manager system. It seems that bpm doesn't have a copy of your wonderful library. are you planning to release it as a bpm package? soon? if not, let me know and i might just do that for my own sanity.

Cheers
Mr Rogers

Add namespace for resource URL

Currently, there is no option to specify the namespace for resource URL. People can reopen ResourceAdapter to add namespace:
Ember.ResourceAdapter.reopen({
ns: 'json/v1'
});
However Ember-REST still need to be changed to accept this namespace:

_resourceRequest: function(params) {
params.url = this.ns + this._resourceUrl();
...
...
}

Rails 3.2 render :json differences

It appears that rails 3.2 implements render :json a bit differently than rails 3.1 did for arrays -- it generates an object with a property named after the resource instead of just returning a json array.

So instead of [], you get {resources: []}

This breaks findAll for me. I fixed it by overriding findAll in my controllers. I'm not sure what a good overall fix would be, however, as there is currently no setting with the plural form of the resource name, which is what is required to access the array inside the returned json object.

Here's my crappy fix for my categories controller:

  findAll: function(){
    var self = this;

    return this._resourceRequest({type: 'GET'})
    .done(function(json) {
      self.clearAll();
      self.loadAll(json.categories);
    }); 
  }

destroy is an Emberism

Ember.Object uses destroy. You should rename Ember.Resource#destroy to something like destroyResource and similarly with the save method so they are named consistently.

cc @ColinCampbell

destroyResource being called 2 times

when i call .destroyResource() in an Em.Resource object, it fires the function 2 times, so generates 2 DELETE xhr requests.

I checked the button that fires the function that calls destroyResource, and its ok, calling it just one time, so i think it might be a issue with ember-rest.js. Any clue?

the code:


App.user = Em.Resource.extend({
    resourceUrl:"testObjects.php",
    resourceIdField:"_id",
    resourceProperties:['nome','email','id','senha']
});

App.users = Em.ResourceController.create({
    resourceUrl:"testObjects.php",
    resourceType:App.user
});

App.novoUsuarioView = Em.View.extend({
    criar:function(){
        var novoUsuario = App.user.create({nome:this.get("nome"), email:this.get("email"), senha:this.get("senha"), status:0});
        App.users.load(novoUsuario);
        novoUsuario.saveResource();
        App.log(novoUsuario.getProperties("nome","email", "senha"));
    },
    load:function(){
        App.users.findAll();
    }
})

App.usersView = Em.View.extend({
    contentBinding:'App.users',
    didInsertElement:function(){
        var self = this.$();
        self.find(".showUser").hover(function(){
            $(this).stop(true).animate({
                backgroundColor:"#bbb"
            },200)
            $(this).find(".userOptions").stop(true,true).fadeIn(200);
        }, function(){
            $(this).stop(true).animate({
                backgroundColor:"#ddd"
            },100)
            $(this).find(".userOptions").stop(true,true).fadeOut(100);
        });
        self.find(".edit").click(function(){
            self.find(".editUser").show(0);
        });
        self.find(".cancel").click(function(){
            self.find(".editUser").fadeOut(200);
        })
    },
    templateName:"usuarios",
    removerUsuario:function(){
        console.log("chamou a action");
        var object = this.get("usuario");
        this.$("div:first-child").slideUp(100, function(){
            //App.users.destroyResource(object);
            object.destroyResource().fail(function(e){
                console.log("Error");
                console.log(e);
            }).done(function(e){
                App.users.removeObject(object);
                console.log("success!");
                console.log(e);
            });
        });
        
    },
    editarUsuario:function(){
        var usr = this.get("usuario");
        view.appendTo("#holder");
    }
})

Add version and compatible Ember.JS version

Add version to Ember-REST with compatible Ember.JS versions in the documentation.

Sorry I didn't include a pull, I don't know what versioning scheme you rather use, which version it is supposed to be now and which Ember.JS versions it is supposed to be compatible with.

ResourceController default resourceUrl

The ResourceController objects can only access it's default resourceUrl (resourceType object's resourceUrl) only if the resourceType object is created, don't work if its just extended, otherwise, i have to define it manualy in the ResourceController object. Its the intended behavior?

Name in Ember.Resource clashes with properties: ['name']

When i have a name property like this :

App.Contact  = Ember.Resource.extend({
  url:        '/contacts',
  name:       'contact',
  properties: ['name'],
 ....

The name property is being used in the json as :

{"value of property name"=>{"name"=>"value of property name"} 

when i post a form using the edit template

{{#with contact}} 
{{view Ember.TextField valueBinding="name" placeholder="name"}} 
{{#if id}} 
{{submitButton "Update"}} 
{{else}} {{submitButton "Create"}} 
{{/if}}
{{/with}}

thanks a lot for all the help 

saveResource() always a POST

I'd like to update paramaters, for example set a field true to false, however, whenever I call saveResource(), I am creating a new record in the database rather than update an existing one.

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.