Apache Cordova: iOS click event not working – Quick „how to“

When you are using Apache Cordova to create apps, you will most likely use click  events to navigate from one view to another or to do other stuff.

This all works fine on Android devices, but iOS is not doing anything – and you won’t get an error in the debug console, either.

The problem is that iOS is not sending a click  event, but touchstart .

So your event listener should look somewhat like the following.

This will let you register your event listener for both the click event  and the touchstart event .

Get next day of week in JavaScript – strtotime equivalent

Sometimes it is necessary for coders to get the next monday, tuesday, wednesday orany other day of the week.

As a PHP coder, I can simply use the strtotime()  function in PHP to get a timestamp for, let’s say,  next wednesday. The code would look like this

Now, there is no JavaScript equivalent to PHPs strtotime  function. So I needed to find one or write my own function to get the Date  object of the next occurence of a given day of week. Get next day of week in JavaScript – strtotime equivalent weiterlesen

Check all checkboxes with jQuery and trigger change event

With jQuery, it is easy to check and uncheck all checkboxes on a page. But that does not fire the change event of the changes checkboxes. But what do you do if you need to have to do something when the status of the checkboxes changes? It’s actually quite easy.

Here is what we are going to achieve:

So what we are going to do is

  • Set up an event listener which fires when the „Check all checkboxes“ checkbox is being checked or unchecked ( change event )(phew, loads of checkboxes there…)
  • Set up an event listener which fires when one of the checkboxes (or all of them) is being changed.

I have set up 30 checkboxes to play with:

The first listener: What to do when one of the boxes is being checked.

Here, we are setting up the event listener to listen for the change event  of the checkboxes with the class checkme . Once the event fires, the surrounding label’s text color is set to red in case the checkbox is checked. Otherwise, it’s set to black.

If you check or uncheck a checkbox now, the color will change. Yay, it’s working.

Let’s check them all!

Here’s a bit of JavaScript that does exactly that:

Notice the .trigger('change')  at the there? This part „manually“ triggers the change event  of the changed elements.

And hey, this even works with Foundation’s Colored Switches! (See it in the demo below).

Oh yeah, here’s the demo :)

Hope I could help :)

Mustache.js: return rendered result to callback function

While using mustache.js, I wanted to return the rendered result from mustache to a callback function instead of simply filling any element’s innerHTML directly.

Just to make it easier for some of the people like me  – and to have this code easily available for myself later – I am writing this short how-to. Mustache.js: return rendered result to callback function weiterlesen

Foundation 6 Tabs by URL anchor link / deep_linking

If you are trying to use the Foundation 6 (Foundation for Sites) Tabs with deep_linking: true, as it says in the documentation, you are in for a bad surprise.

Foundation 6 Tab deep-linking is not yet supported.

As a workaround, I have put up a little bit of Javascript to be used to deeplink to the tabs by the URL anchor hash.

Even Zurb Foundation has sent people to my page to use this workaround until they fix it :)

I have put this up on Github as well so you can make it better :)