Questions tagged [javascript]
The javascript tag has no summary.
129 questions
0
votes
1
answer
258
views
Setting up a new Next.js app with Craft
I'm having trouble fetching data in a new Next.js app from Craft.
I'm on Next 15.0.3 and Craft 5.5.
I've got CRAFT_CMS_GRAPHQL_TOKEN and CRAFT_CMS_GRAPHQL_ENDPOINT set up in my .env file.
I've got '...
0
votes
2
answers
221
views
NGINX Cache Configuration Causing 404 Errors for Dynamic JavaScript Files in Craft CMS 5
I'm working with Craft CMS 5 using a local environment configured through DDEV, which defaults to NGINX. I typically work with Apache, so I've been adjusting my caching rules for NGINX to ensure ...
2
votes
1
answer
204
views
How to inform the front-end user that their session is about to expire?
I have a Craft CMS 4 with forms for logged-in users.
Some users may keep certain pages open in their browsers.
Sometimes, users submit the form while their session has expired (after one hour, in this ...
0
votes
0
answers
107
views
Craft 2 - Referencing Twig Variables in Javascript - Variables Do Not Exist
I'm working with a template in Craft 2, and in referencing Twig variables in the Javascript, they are not recognized when the page is previewed. I get a Template Error - Variable x does not exist
...
1
vote
2
answers
453
views
Element In Template Not Hiding On Page Load
I'm working on a template in Craft 2, and I have a number of divs which are part of a Javascript "read more" script, which automatically shortens the visible text at a set number of ...
1
vote
1
answer
246
views
Add Google Analytics JS event tracker
I'm trying to track some link clicks on a website that is using Craft CMS.
I only have access to the Website and the Data Studio Report, but I don't have access to Google Analytics, GTM or any "...
1
vote
3
answers
424
views
How to use page specific javascript using asset rev plugin and webpack?
I have a similar question here.
But I was NOT able to ask the right question.
I'm practicing with starter-blog template.
How do I use page specific javascript using the asset rev plugin and webpack?
I ...
1
vote
1
answer
69
views
How to use page specific javascript using the starter-blog template using asset rev plugin?
I'm practicing with starter-blog template.
How do I include a page specific javascript using the asset rev plugin?
Thanks.
2
votes
1
answer
1k
views
Escaping quotes of an entry string used inside a script tag
How can I display an entry string, with included special characters (like single and double quotes) , inside a script tag without translating these special characters into html entities but escaping ...
2
votes
2
answers
217
views
Hiding categories in real time with Sprig in a faceted search
I've built three buttons with checkbox dropdowns that display categories that filter the content below based on categories. I am currently using the relatedTo function to only display the categories ...
2
votes
1
answer
590
views
404 Error Controller Action From Jquery But Not Url
I'm able to call my controller action directly from a url in the browser and get the proper response but when I call it from a page with js I get a 404 error. I'm working off the solution found here ...
1
vote
1
answer
38
views
I have a custom table in my craft plugin at the backend and I have to include custom sorting on each field of the table using javascript
The Table includes this field:
Name
Age
City
State
1
vote
1
answer
342
views
Loading JavaScript on Template Load
I'm working on a kiosk-type plugin which will cycle through all news entries, beginning upon template (or page) load.
It needs to load a JavaScript ajax script for this on page/template load.
Would ...
1
vote
1
answer
97
views
Showing and hiding details (price, sale price, sku etc)when product variant is selected on details page
I currently have price, sku and variant title swapping when clicking between variants on a products details page.
This works with AlpineJS and looks something this.
https://codepen.io/amasci/pen/...
2
votes
1
answer
823
views
Re-initialize / layout Masonry after a sprig change
I've got Sprig set up to filter entries by a few categories. I'm trying to re-layout Masonry JS after this update takes place.
For starters, I add Masonry to the window variable (defined as global in ...