Skip to content

Commit f5fd7fe

Browse files
authored
Merge branch 'Develop' into Updates-to-CMS-Filter
Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
2 parents 95bf9dd + c1a3905 commit f5fd7fe

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

Dist/WebflowOnly/CMSFilter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ class CMSFilter {
418418
const datasetValue = (item.dataset && item.dataset[category]) ? item.dataset[category] : '';
419419
const itemValue = parseFloat(datasetValue);
420420
if (isNaN(itemValue)) return false;
421-
422421
if (value.from !== null && value.to !== null) {
423422
return itemValue >= value.from && itemValue <= value.to;
424423
} else if (value.from !== null && value.to == null) {

Dist/WebflowOnly/RenderStatic.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class RenderStatic {
44
constructor(_container) {
55
this.container = _container;
66
this.cloneables = document.querySelectorAll("[wt-renderstatic-element='cloneable']");
7+
this.resetIx2 = this.container.getAttribute('wt-renderstatic-resetix2') || false;
8+
79
this.gap = 0;
810
this.observer = null;
911

@@ -49,6 +51,7 @@ class RenderStatic {
4951
let childClone = child.cloneNode(true);
5052
if (parent) {
5153
parent.insertBefore(childClone, parent.children[index]);
54+
if(this.resetIx2) this.ResetInteraction(childClone);
5255
}
5356
}
5457

@@ -68,6 +71,38 @@ class RenderStatic {
6871

6972
this.observer.observe(this.container, { childList: true });
7073
}
74+
75+
ResetInteraction(element) {
76+
if (!element) {
77+
console.error('Element not found');
78+
return;
79+
}
80+
81+
const WebflowIX2 = window.Webflow && Webflow.require('ix2');
82+
if (!WebflowIX2) {
83+
console.error('Webflow IX2 engine not found.');
84+
return;
85+
}
86+
87+
const targetElement = element.hasAttribute('data-w-id')
88+
? element
89+
: element.querySelector('[data-w-id]');
90+
91+
if (!targetElement) {
92+
console.warn('No IX2 interaction found on the element or its children.');
93+
return;
94+
}
95+
96+
const dataWId = targetElement.getAttribute('data-w-id');
97+
if (dataWId) {
98+
targetElement.removeAttribute('data-w-id');
99+
targetElement.setAttribute('data-w-id', dataWId);
100+
101+
WebflowIX2.init();
102+
} else {
103+
console.warn('No valid data-w-id attribute found.');
104+
}
105+
}
71106
}
72107

73108
const initializeRenderStatic = () => {

docs/WebflowOnly/CMSFilter.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ Your CMS items should include data attributes that match your filter categories.
237237

238238
### JavaScript API
239239
Access the filter instance globally:
240+
241+
> **Note:** The following example uses [optional chaining (`?.`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining), which is supported in all modern browsers but **not** in Internet Explorer or some older browsers. If you need to support older browsers, use the alternative code below.
242+
243+
**Modern browsers (with optional chaining):**
240244
```javascript
241245
// Get the filter instance
242246
const filterInstance = window.webtricks.find(item => item.CMSFilter)?.CMSFilter;

0 commit comments

Comments
 (0)