Skip to content

Instantly share code, notes, and snippets.

@bgriggs1
bgriggs1 / gist:5cf2d1e60c203e384daa
Created November 13, 2014 20:47
List theme for Knack jobs app
/* Font styles */
.kn-content h3 {
color: #8f3181;
margin-top: 18px;
margin-bottom: 8px;
line-height: 160%;
font-size: 115%;
}
body .kn-content p {
line-height: 160%;
@bgriggs1
bgriggs1 / gist:6107ed1238405415c254
Created October 13, 2014 15:45
Update a date/time field with an inline table edit
// this event handler will update a date/time field when a value is updated with inline editing
// change view_1 to the view key of the table with inline editing
$(document).on('knack-cell-update.view_1', function(event, view, data) {
// create a JS date object
var todayDate = new Date();
todayDate.setHours(todayDate.getHours() - 7); // make any timezone changes
// create an object for the data to update
@bgriggs1
bgriggs1 / gist:43fc986cf1a539c30b70
Created September 22, 2014 04:56
Set the width of a table column
/* Change the view_1 to the key of your table view */
/* Change the field_1 to the key of the field of the column you want to set */
#view_1 th.field_1 {
width: 100px; /* width in pixels */
}
// api
var api_url = 'http://api.knackhq.com/v1/objects/object_1/records';
// preparing filters
var filters = [
{
field: 'field_1',
operator: 'is',
value: 'test'
@bgriggs1
bgriggs1 / gist:5275077
Last active December 15, 2015 14:29
CSS Example: Menu
/* Knack's version */
#kn-app-menu ul {
background-color: #00396D;
}
/* Your custom gray version. Add a selector to prioritize */
.kn-content #kn-app-menu ul {
background-color: #ccc;
}
@bgriggs1
bgriggs1 / gist:4992925
Created February 20, 2013 04:39
Updating a contact record
{
"field_1": "Kelly and Cohen",
"field_16": "4347 Oak Street<br />Syracuse, NY 13202",
"field_17": {
"url": "http://www.kellycohen.com"
},
"field_18": "Services",
"field_31": "315-296-4146"
}
@bgriggs1
bgriggs1 / gist:4992920
Created February 20, 2013 04:37
Updating single field
{
"field_1": "Kelly and Cohen"
}
@bgriggs1
bgriggs1 / gist:4992691
Created February 20, 2013 03:42
"both" return format example
{
field_1: "02/08/2013 to 02/11/2013",
field_1_raw: {
"date":"02/08/2013",
"to":{
"date":"02/11/2013"
},
"all_day":true
}
}
@bgriggs1
bgriggs1 / gist:4988787
Last active December 13, 2015 22:59
Handling a record update event triggered by Knack
// change view_1 to the view you want to listen to
$(document).on('knack-record-update.view_1', function(event, view, record) {
// view is a json object of the form
// record is a json object of the record inserted by the view (form)
alert('updated a record for view: ' + view.key);
});
@bgriggs1
bgriggs1 / gist:4988743
Last active December 13, 2015 22:59
Handling a records render event triggered by Knack
// change "view_1" to the view you want to listen for
$(document).on('knack-records-render.view_1', function(event, view, records) {
// handle scene
// view is a json object of the view
// records is an array of json objects of the records currently visible
alert('listener for records, # of records is: ' + records.length);
});