Category Archives: JavaScript

Google Maps API Key Issue

Last weekend I was perplexed to find that Google Maps had apparently broken, but only when running my site locally – the production site seemed unaffected. The map would load and then after a couple of seconds it would be … Continue reading

Posted in JavaScript | Leave a comment

Notes on deploying a MongoDB-backed Express app to Heroku

Reference: Getting Started with Node.js on Heroku Preparing your application for deployment Use the configured port Reference: Gotchas for Node JS apps on Heroku Make sure it listens on the port defined in process.env.PORT. If it’s set to listen on … Continue reading

Posted in Node.js, Version Control | Leave a comment

AngularJS: Watching a collection

I was recently in a situation in one of my AngularJS projects where I wanted to perform an action if the content of an array assigned to a property on the scope changed (e.g. if an item was added or … Continue reading

Posted in AngularJS | Leave a comment

Binding Isolated Scopes in AngularJS

In AngularJS an isolated scope does not inherit properties from its parent scope, unlike a child scope. However, a property of an isolated scope in a directive can be bound to an attribute, which in turn can be bound to … Continue reading

Posted in AngularJS | Leave a comment

Working with Dates in JavaScript

Given the quite limited built-in functionality for working with dates in JavaScript, here are some bits and pieces I have found useful. Comparing two dates by value: oDateOne – oDateTwo === 0 (http://stackoverflow.com/a/7961381) Checking if a string converts to a … Continue reading

Posted in JavaScript | Leave a comment

jQuery and JavaScript for Debugging

Here are a few of the JavaScript and jQuery methods which I find useful when debugging my projects. JSON.stringify() can be used to inspect objects To inspect the value of element attributes like class or id, use .attr() e.g. $(‘#myelementid’).attr(‘class’) … Continue reading

Posted in JavaScript | Leave a comment

Displaying HTML-formatted documents without HTML

Most of the documents displayed on my genealogy website conform to one of a limited number of formats and I’ve created an HTML template for each format required. However, I also have some free-form text documents which I wanted to … Continue reading

Posted in JavaScript | Leave a comment

Selecting Child Elements in jQuery

I was recently asked whether it would be ‘better/quicker’ to replace $(‘ul’).children(‘li’).children(‘a’) with $(‘ul li a’) My initial response was to warn that these two lines of code don’t actually do the same thing. As explained in the jQuery API … Continue reading

Posted in JavaScript | 1 Comment