The Original Jelani Harris The one and only


Fixing Foundation 5’s Unrecognized Expression Syntax Error


I was working on a new marketplace theme in Magento, and I kept getting a peculiar javascript error message. The exact error message that you might receive could vary - but the one I got was:

Uncaught Error: Syntax error, unrecognized expression: [data-'Times New Roman'-dropdown]

Huh? What? But it was the version of Jquery (2.1.1) that I was using that was causing this error. After some poking around (i.e. disabling everything and re-enabling every js file piece by piece), I discovered that the source of this issue is from Foundation's internal namespace.  If you set the namespace to be blank before you activate Foundation, the error goes away. = '';

By setting the Foundation's global namespace to be blank, Foundation won't attempt to set it. I'm not sure why I got this error but doing this allowed me to keep working and hopefully you too.



Removing empty elements from an array

When dealing with tag inputs from users, I find myself having to make sure they they don't enter in any blank or empty tags. Then I realized that I needed to find out how to remove undesirable elements not only from the Php side, but also from the Javascript side as well. Thus, here are some functions that may help some other people out if they're searching for similar functionality.


    foreach ($my_array as $key => $value) {
      //We check to make sure that the value is either null or just an empty string
      if (is_null($value) || $value=="") {

An easier way to clean arrays is to use php's array_filter function without a callback parameter. By default that function is set to remove elements that contain a false (or a 0), null or a "". I mean seriously, look at how much cleaner it is:

   //This prunes out 'false', '0', 'null' or ''
   $my_array = array_filter($my_array);

In JavaScript

We can mimic the functionality of Php's array_filter in Javascript by using the Array.filter function.

   var my_array = [1,2,3,'4','', 0, null, 'false'];
   function emptyElement(element) {
	//Removes nulls, zeros (also falses), text version of false, and blank element
	if (element == null || element == 0 || element.toString().toLowerCase() == 'false' || element == '')
		return false;
		else return true;
	var my_array = [0,'false',1,null, 2,'',3,'4',false];
	my_array = my_array.filter(emptyElement);

Then my_array will include 1,2,3,4.

I hope this was somewhat useful.

Tagged as: , 1 Comment