Skip to content

Inviz/mootools-thingies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jester ported to mootools
Result or syntax may vary
But the code's much better

  var Post = new Resource("Post")
  Post.find("all", function(p) {
    p.title = "All your base are belong to us"
    p.save
  })

  p = new Post({title: "Hello world"}).save
  p.errors #=> {something}

This thing is rails & merb-oriented
As they are supported out of the box:

Merb, with Merb.disable(:json) & ActiveRecord:

  provides :json
  display @post, :only => [:title, :body, :created_at, :id], :include => {:comments => {:only => [:body, :created_at, :id]}}

Merb without ActiveRecord:

  provides :json
  display @post #cant control anything here, associations not included

Rails:

  respond_to do |f|
    f.json do
      @post.to_json, :only => [:title, :body, :created_at, :id], :include => {:comments => {:only => [:body, :created_at, :id]}}
    end
  end

So with that backend we can do this: 

  new Resource("Post", {
    associations: {
      comments: ["Comment", {prefix: true}] #setting autoprefix on 
    } 
  })

  Post.find(1).chain(function(post) {
    post.title = "defaced"
    post.comments.each(function(comment) {
      comment.destroy() # DELETE /posts/1/comments/n
    })
    post.save().chain(function(result) {
      if (!result) {
        alert(post.errors) # => ["Title is too short"]
      } else {
        alert("Ha ha ha... You are on your way to destruction")
      }
    }) # PUT /posts/1/ title=defaced
  })

About

Various mootools widgets packed altogether.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published