Developer Forum »
How does $('meta[name= ... works?
62 posts

Hi!

I get an error in my javascript. When I try to call getSizesForColor(), nodeId is empty. I can see in "page source" that NODE-ID is included in the top of the page. But how is this related to the meta-tag? 

 

$(document).ready(function () {
               $(".radio").click(function () {
                   var colorId = $(this).attr("id");
                  $(".switcher li").hide();
                  $(".switcher li." + colorId).show();

                   $('.switcher li a').removeClass('zoomThumbActive');
                   $(".switcher li." + colorId + ":first a").click();
                   var nodeId = $('meta[name=node-id]').attr("content");
                   var sizeId = $(".radio-size").val();
                   productHub.getSizesForColor(colorId, nodeId, sizeId)
                                   .done(function (result) {
                                       updateSizesResult(result);
                                   })
                                   .fail(function (e) {
                                       console.warn(e);
                                   });
               });
           });

 

 

PAGE SOURCE:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   <title>...</title>   <link media="all" rel="stylesheet" type="text/css" href="/Templates/css/all.css" />   <!-- GENERATOR: Webnodes -->   <!-- ABOUT: http://www.webnodes.com -->   <!-- CMS-BUILD: 1454 -->   <!-- LICENSE: 32644 -->   <!-- NODE-ID: 14300 -->   <!-- LCID: 1044 -->   <!-- CREATION-DATE: Tue, 24 Jan 2012 22:59:00 GMT -->   <!-- LAST-MODIFIED: Wed, 07 Mar 2012 14:20:52 GMT -->

 

 

181 posts

Hi!

It's a bug in the demo site due to changes to the Webnodes core. In earlier releases, a few pieces of information about the site and page was included in meta tags. But since they weren't standard meta tags, some validations failed with them present. So we changed to having the data as html comments rather than meta tags. The script tries to fetch the nodeId from a meta tag, but the meta tag it's looking for isn't present, so the value to the function is 0, which will fail.

I'll create an update to the shop demo site today or tomorrow. I'll update this thread when the new version of the demo site is ready.

1