Skip to content

Instantly share code, notes, and snippets.

//Put your real collection constructors here. Just examples.
var collections = {
Languages: Backbone.Collection.extend(),
ProductTypes: Backbone.Collection.extend(),
Menus: Backbone.Collection.extend()
};
function fetch() {
$.getJSON("/url/to/your/big.json", {
success: function (response) {
@phungnc
phungnc / dynamic model
Created January 24, 2013 16:16
lets say i have a small app to store and manage contact details (an address book) i have multiple users that can login and they each have their own collection of contacts... ref: http://stackoverflow.com/questions/7385629/backbone-js-complex-views-combining-multiple-models
var model = new Backbone.Model();
model.set({contacts: new ContactsModel(), users: new UsersModel()});
var view = new GridView({model: model});
var contacts = new ContactsModel();
var users = new UsersModel();
var view = new GridView({model: contacts, users: users})
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.com/bootstrap/assets/js/bootstrap.js"></script>
<meta charset=utf-8 />
</head>
<body>
fullsize: function(ev) {
var target = ev.currentTarget;
var self = this;
$('.drop-shadow').click(function(inner_ev) {
console.log(this.id); // the same as inner_ev.currentTarget
console.log(self.cid); // the containing view's CID
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy

Step 1: Clone the bundles into your Sublime Text packages directory

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
git clone git://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
git clone https://github.com/miksago/jade-tmbundle.git Jade
git clone https://github.com/LearnBoost/stylus.git Stylus

Step 2: Restart Sublime Text 2

@phungnc
phungnc / provider, factory, service source code in Angular.js
Created December 6, 2013 08:15
the difference between service, factory, provider in angular.js
// Below is the source code pick from angular.js
// Read source code help us more clearer
// the difference between service, factory, provider
function provider(name, provider_) {
if (isFunction(provider_) || isArray(provider_)) {
provider_ = providerInjector.instantiate(provider_);
}
if (!provider_.$get) {
throw Error('Provider ' + name + ' must define $get factory method.');
}
@phungnc
phungnc / settting.json
Created March 28, 2020 23:41
vscode setting
{
"window.zoomLevel": 2,
"workbench.colorTheme": "Night Owl",
"workbench.iconTheme": "material-icon-theme",
"workbench.sideBar.location": "left",
"editor.minimap.enabled": false,
"explorer.confirmDelete": false,
"javascript.updateImportsOnFileMove.enabled": "always",
"git.confirmSync": false,
"extensions.ignoreRecommendations": false,