End Your If

Helping you solve those tough coding problems!

Learn some great development tips and techniques through recipes that clearly define the problem being solved with a working solution.
Popular Tags: cakephp | theory | optimization | javascript-development | asp-net | ajax | sql | php-development | jquery-development | css

Search:
Follow @endyourif rss Facebook LinkedIn
My Books

Difference between location.href and location.replace Difference between location.href and location.replace

Published on Feb 9, 2018 by Jamie Munro

It's quite common to redirect a user visiting your webpage, more specifically when they perform an action, such as: clicking a button. When the user completes the action and you want to redirect the user to somewhere else, you have two common choices:
window.location.href = '';


OR
window.location.replace('');


Read more >

Tags: Javascript | JavaScript | location.href | location.replace

Retrieving query string variables with JavaScript Retrieving query string variables with JavaScript

Published on Feb 8, 2018 by Jamie Munro

This is not something I use everyday. Seems more like a once a year thing. Last time I needed to extract query string variables, I used the old school approach with a regular expression. Now that I need to do this again, I can use the new school approach: URLSearchParams.

The URLSearchParams (at the time of writing) is not yet standardized in the W3C; however, most modern browsers recognize it.

Let's start by looking at the old school way using regular expression to compare how much easier it is when browsers begin working together to support ease-of-use:

Read more >

Tags: Javascript | JavaScript | regexp | urlsearchparams

Zero Padding a Number with JavaScript Zero Padding a Number with JavaScript

Published on Feb 7, 2018 by Jamie Munro

This morning I had to format a date using JavaScript as follows: yyyymmdd requiring both the month and day to include a leading zero when the month or day was less than 10.

A nice solution I found was as follows:

Read more >

Tags: Javascript | JavaScript | slice

Knockout - Uncaught ReferenceError: Unable to process binding Knockout - Uncaught ReferenceError: Unable to process binding

Published on Oct 27, 2014 by Jamie Munro

If you've used Knockout.js in your project, at some point or another you've probably encountered the following error "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.

I recently encountered this issue and could not find the typo anywhere. Like most developers in my situation I was getting really frustrated, banging my head against the world looking for answers.

Unfortunately, there is no easy answer to this bug; however, I can suggest an excellent technique that will hopefully help point you in the right direction.

Here is a complete example that creates a table and displays a list of books within the table. There is an unfortunate typo within one of the td data bindings.

Read more >

Tags: Javascript | KnockoutJS | knockoutjs | data binding | debugging

Javascript, the Back Button, and Windows Phone 8 Development Javascript, the Back Button, and Windows Phone 8 Development

Published on Feb 18, 2013 by Jamie Munro

I recently had the opportunity to begin exploring and toying around with Windows Phone 8 development.

Why you ask?  Why not really, but mostly because I was giving a free phone and it’s an untapped market when it comes to apps.  At this stage it’s not over diluted like the Android and iPhone stores are.  That and of course there is an option to create apps using HTML, Javascript, and CSS – technologies I’ve used and mastered for years!

I actually submitted my first app last weekend – and sadly – it got rejected :(  I was given two reasons; firstly I did set a default application icon, whoops my bad.  Secondly, I didn’t properly handle the back button since there are “multiple pages” in my application.

It took me several hours to finally found the answer so I thought I would share it.  Please note, this feels like a bit of a hack, but I wasn’t able to get the “suggested” solutions working…

Read more >

Tags: Javascript | ASP.NET | c# | JavaScript | Windows Phone | wp8 | windows phone 8

JavaScript: Easy Creation of "Countdown Timers" JavaScript: Easy Creation of

Published on Aug 28, 2012 by Jamie Munro

Maintaining the back button with AJAX Maintaining the back button with AJAX

Published on Dec 28, 2010 by Jamie Munro

Facebook Development - Quick and Easy Dialogs Facebook Development - Quick and Easy Dialogs

Published on Jun 10, 2009 by Jamie Munro

Drag and drop with animations in jquery Drag and drop with animations in jquery

Published on Mar 10, 2009 by Jamie Munro

Fixing slow drag and drop with scriptaculous Fixing slow drag and drop with scriptaculous

Published on Feb 18, 2009 by Jamie Munro

Drag and Drop with AJAX Example Drag and Drop with AJAX Example

Published on Feb 14, 2009 by Jamie Munro

YSlow - Helping slow web pages load faster YSlow - Helping slow web pages load faster

Published on Feb 11, 2009 by Jamie Munro

Firebug - A developer's best friend Firebug - A developer's best friend

Published on Feb 11, 2009 by Jamie Munro