Skip to content

Instantly share code, notes, and snippets.

View arendjr's full-sized avatar

Arend van Beelen jr. arendjr

View GitHub Profile
var model = new LacesModel({
selectedRoom: null
});
var tie = new LacesTie(model,
'<p><label>Name:</label> <span data-laces-property="selectedRoom.name"></span></p>' +
'<p><label>Description:</label> <span data-laces-property="selectedRoom.description"></span></p>'
);
document.body.appendChild(tie.render());
var tie = new LacesTie(model,
'<p><label>Name:</label> <span data-laces="{ property: selectedRoom.name, editable: true }"></span></p>' +
'<p><label>Description:</label> <span data-laces="{ property: selectedRoom.description, editable: true }"></span></p>'
);
document.body.appendChild(tie.render());
var tie = new LacesTie(model,
'<p><label>Name:</label> <span data-laces="{ property: selectedRoom.name, editable: true }"></span></p>' +
'<p><label>Description:</label> <span data-laces="{ property: selectedRoom.description, editable: true }"></span></p>', {
editEvent: 'click'
});
document.body.appendChild(tie.render());
@arendjr
arendjr / extend.js
Last active February 1, 2024 18:02
Backbone's extend() method
/**
* Extend method copied from Backbone.js 1.1.0
*
* (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc.
* (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Backbone may be freely distributed under the MIT license.
* For all details and documentation:
* http://backbonejs.org
*/
function extend(protoProps, staticProps) {
@arendjr
arendjr / model.js
Created November 23, 2013 13:54
Laces.js-based Model implementation
/**
* Base class for all models.
*
* @param application Application instance.
* @param attributes Optional map of attributes to assign to the model.
*/
function Model(application, attributes) {
if (!application) {
console.log("Model instantiated without Application reference");
@arendjr
arendjr / collection.js
Created November 23, 2013 13:59
Laces.js-based Collection implementation
/**
* Base class for all collections.
*/
var Collection = Model.extend({
constructor: function() {
Model.apply(this, arguments);
/**
@arendjr
arendjr / view.js
Created November 23, 2013 14:40
Custom View implementation
/**
* Base class for all views.
*
* @param context Application or View instance that serves as a context for this view. If a
* View instance is given, it is assumed to be the parent view.
* @param options Optional options object. May contain the following properties:
* $el - jQuery container containing the top-level element to be used by this
* view. If none is given, a new element is created for the view.
*/
function View(context, options) {
@arendjr
arendjr / router.js
Created November 23, 2013 15:05
Backbone.js-based Router implementation
function Router() {
var self = this;
setTimeout(function() {
window.addEventListener("popstate", _.bind(self._onStatePopped, self));
self._activateRoute();
}, 0);
}
@arendjr
arendjr / continuouspager.js
Created November 23, 2013 15:40
ContinuousPager class
/**
* Base class for continuous pagers.
*/
return View.extend({
constructor: function() {
/**
* The collection to render in the pager.
*/