Streaming live at 10am (PST)

JSON ARRAY of Strings - Problem


#1

Hello,

I need to add a json array of strings for data-group, like for example
data-groups='["All"]'

However, Webflow is automatically doing this, data-group="'["All"]'" - Webflow is automatically adding quotation marks, which sort of blocks my workflow =/


#2

I just ran into this issue. I am adding a custom attrbute to an element as

data-options={"mouseDrag": true,"autoHeight": true,"autoPlay": false,"navigation": true,"navigation_pos": "center","pagination": false,"pagination_pos": "center-top","slideSpeed": "200","desktop": "3","desktopsmall": "3","tablet": "2","mobile": "1","callback": ""}

Webflow outputs this as

data-options={'mouseDrag': true,'autoHeight': true,'autoPlay': false,'navigation': true,'navigation_pos': 'center','pagination': false,'pagination_pos': 'center-top','slideSpeed': '200','desktop': '5','desktopsmall': '3','tablet': '2','mobile': '1','callback': ''}

The problem here is that the script then sees this as a string and not an object and throws an error:

Uncaught TypeError: Cannot create property 'theme' on string '

I was eventually able to fix this by replacing the quotes and then making it an object using this:

if(typeof(options) !== 'object') {
     var options = options.replace(/'/g, '"');
     var options = JSON.parse(options);
}

However this should not be required. Any insights on this from the Webflow team? If the string kept the double quotes I add instead of making them single quotes this would work as normal.


#3