The .call() method is a JavaScript built-in that allows you to call a function that is defined in another object. Here is what w3schools.com says about the .call() method: The first argument when using .call() will always be expected to be an object that contains keys that the calling function requires as arguments. For example: … Continue reading JavaScript: How to use the .call( ) method
JavaScript
Javascript: How to use ES6 Template Literals
When using ES6 with a linter I got this suggestion from sonarqube to replace my standard string concatenation with an apparently preferred Template Literal. Here is the sonarqube message I got: The string concatenation that triggered this suggestion was: The suggested fix using a Template Literal looks like this: Basically, a template literal has this … Continue reading Javascript: How to use ES6 Template Literals
Vue.js: How to make an identicon generator
In this article, I will show how to create an identicon generator using Vue.js in codepen. First of all, an identicon is a graphical image that is generated by text input. This is useful as a substitute for photo images for site users. For example, when I type “Chris Nielsen Code Walk”, the identicon generator … Continue reading Vue.js: How to make an identicon generator
Node.js: How to launch a temporary server and view output in a web browser
Once you have successfully written some node.js code and have viewed the results via command line, (see my previous article about this, linked below) the next logical step is to be able to write node.js code that can use HTML and be viewable in a web browser. To view node.js output in a web browser, … Continue reading Node.js: How to launch a temporary server and view output in a web browser
Node.js: How to write node.js code locally and test using the command line
The first thing we want to do when getting ready to code in node.js is make sure that Node and NPM are installed on our machine. Start by opening a command window and type the command node -v. Then check to confirm that NPM is installed also using the command npm -v: Once that is … Continue reading Node.js: How to write node.js code locally and test using the command line
jQuery: How to detect if JavaScript and jQuery are working in a sandbox environment
Recently I was working in a Piano template sandbox environment where I could edit HTML and CSS code to build a Piano template. This sandbox uses AngularJS, HTML, and CSS, but I wanted to see if it provided JavaScript and jQuery functionality so that I could enhance the template I was working on with some … Continue reading jQuery: How to detect if JavaScript and jQuery are working in a sandbox environment
JavaScript: How to call a Python script and get the results via jQuery
Let’s say you have a situation where you need to read JSON data from an API and you don’t have plug-in credentials to access the API directly, but you can see the JSON data that is output from the API on a page. In this case, you can still get the data if you “scrape” … Continue reading JavaScript: How to call a Python script and get the results via jQuery
Handlebars: How to use templates
Handlebars supports multiple templates in the same Single Page Application. To use templates with Handlebars, you must define a template id in the opening Handlebars script tag. For example, in this case the name of the template is “verse-set-grid”: <script id=”verse-set-grid” type=”text/x-handlebars-template”> The pattern for a template is: <!– 1. Opening script tag with the … Continue reading Handlebars: How to use templates
Handlebars: How to iterate through an array of objects
When using the Handlebars.js templating system, a common need is to be able to iterate through an array of JavaScript objects in order to build an HTML list. This is useful for ‘Atomic’ web programming, where a component is defined, and you may have a dynamic number of such components in your database. For example, … Continue reading Handlebars: How to iterate through an array of objects
jQuery: How to launch a file upload dialog from a text field
I have a text field with placeholder text that says “No file chosen”. I wanted to add functionality to this so that if the text field is clicked it launches a file upload dialog. Then when a file is chosen, I want the name of the chosen file to appear in the text field. This … Continue reading jQuery: How to launch a file upload dialog from a text field