Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

SuperModel in JavaScript (deprecated! - use http://github.com/maccman/super.js)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 jquery.js
Octocat-spinner-32 superclass.js
Octocat-spinner-32 superevent.js
Octocat-spinner-32 supermodel.js
Octocat-spinner-32 supermodel.marshal.js
README.markdown

SuperModel written in JavaScript; essentially a simple version of ActiveModel in JavaScript.

See http://github.com/maccman/supermodel

Examples:

<script src="javascripts/jquery.js"></script>
<script src="javascripts/superclass.js"></script>
<script src="javascripts/superevent.js"></script>
<script src="javascripts/supermodel.js"></script>

<script type="text/javascript" charset="utf-8">
  var Asset = SuperModel.setup("Asset");
  Asset.attributes = ["name"];

  var a = new Asset({name: "My name"});
  a.save();

  console.log(Asset.find(a.id).name);

  a.name = "My name 2";

  console.log(Asset.find(a.id).name);
  a.save();
  console.log(Asset.find(a.id).name);

  a.destroy();

  // Shouldn't exist
  try {
    console.log(Asset.find(a.id))
  } catch(e) { }


  // Automatically save data in local database
  Asset.extend(SuperModel.Marshal);

  Asset.bind("afterCreate", function(){
    // after create callback
  })
</script>

Roadmap

  • Add validation, at the moment it can be done by throwing errors in filters
Something went wrong with that request. Please try again.