Skip to content

Instantly share code, notes, and snippets.

View bb-multi-collection
//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 Jan 24, 2013
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
View dynamic model
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})
View Twitter Bootstrap_multi_select_dropdown.html
<!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>
View innerEvents
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
View Draggable.js
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
View gist:5377708

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 Dec 6, 2013
the difference between service, factory, provider in angular.js
View provider, factory, service source code 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.');
}
View settting.json
{
"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,
You can’t perform that action at this time.