Category: JavaScript

  • jQuery HTML Templates

    There is an updated version of this article: jQuery HTML Templates: 3 Solutions to get you started

    When you have a lot of AJAX calls on your website, especially ones that return a list of data, it can be quite expensive processing time on the server to retrieve the results, format them with HTML, and return them to the browser to display – not only that, your bandwidth costs can be quite high as well. With jQuery templates, you can alter your AJAX calls to return JSON leveraging Javascript event handlers, and then populate the content client-side providing faster response times and less server processing as well from an external file or JSON object.

    (more…)

  • Knockout – Uncaught ReferenceError: Unable to process binding

    If you’ve used Knockout.js in your project to process binding, at some point or another you’ve probably encountered the following error message Uncaught ReferenceError: Unable to process binding. The most likely cause is a typo somewhere or forgetting to change the context. E.g. you are within a foreach binding and forget to use $parent especially inside your jquery HTML template.

    (more…)

  • Create GUID / Create UUID in JavaScript

    Javascript create guid

    Generate uuid

    Most server-side languages and databases provide built-in support for UUIDs (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier). At the time of writing JavaScript does not, so let’s create our own UUID generator with JavaScript array.

    There are a few other examples out there that use random numbers and date parts; however, I found this solution that leverages window.crypto.getRandomValues. There are also of course of few libraries out there, most notably node-uuid (npm install uuid) for your universally unique identifier, but sometimes it’s fun to create things on our own for experimentation with the crypto api to generate UUID.

    (more…)

  • JavaScript Copy To Clipboard

    This is such a little handy function copy using Javascript copy to clipboard that allows you to create a button that will copy a block of content into the user’s clipboard. The solution is to use the built-in execCommand function.
    (more…)

  • MVVM Pattern – Model View View Model

    Let’s learn all about what MVVM is through practical examples.
    (more…)