Skip to content

Instantly share code, notes, and snippets.

@igustafson
igustafson / settings.snippet.coffee
Created May 3, 2011 21:28
Settings TableView with delete link
class TableView extends Sagamore.Views.CollectionTable
className: "settings"
fields: [
{id: 'actions', title: '', render: (options) ->
$('<a href="#" class="delete">Delete</a>').click ->
if confirm("Are you sure you want to delete user '" + options.model.get("login") + "'?")
options.model.destroy
}
{id: 'id', title: 'Name', sort: true, template: idTemplate}
@igustafson
igustafson / menu.coffee
Created May 4, 2011 21:09
Menu Building Code
Menu = Sagamore.Models.Menu
Entry = Sagamore.Models.Menu.Entry
topMenu = new Menu
entries: [
new Entry title: 'Customers', url: '#/customers'
new Entry title: 'Sales', url: '#/sales'
]
moduleMenus =
@igustafson
igustafson / view.coffee
Created May 5, 2011 16:25
does this work?
class Sagamore.Views.ModuleMenu extends Sagamore.View
initialize: (menu) ->
@menu = menu
render: ->
var EditView = Sagamore.Views.ModelForm.extend({
fields: [
{name: "login", label: "Username"},
{name: "password", label: "Password"}
]
}).extend(Sagamore.Lib.ModalForm)
<?php
return array(
'encryption_key' => 'Z87H4w0Ak5mbmx56ScnUW2xeJkY2qvEG',
'mysql_user' => 'homestead',
'mysql_password' => 'secret',
'mysql_host' => 'localhost'
);
@igustafson
igustafson / reddit_ajax.js
Last active August 30, 2019 03:25
Reddit API AJAX Request Example Using jQuery
var searchTerm = 'cats';
$.ajax(
"https://www.reddit.com/subreddits/search.json",
{
data: { q: searchTerm },
success: function(responseData) {
if (responseData.data.children.length > 0) {
console.log('# of results: ' + responseData.data.children.length);
$.each(responseData.data.children, function(idx, searchResult) {