Questions tagged [javascript]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5
votes
1answer
2k views

Update Commerce Cart using Ajax

Is there a way to update the cart using ajax? I've tried something like: $('span.quick-cart-add>p>a').click(function(e){ e.preventDefault(); var data = {}; ...
4
votes
1answer
3k views

Loading javascript on specific sections/pages

What is the recommended way to add section specific javascript to entry pages? I need to make some 3rd party api calls front end for currency conversion but I want to only use it on a specific ...
2
votes
1answer
1k views

Can you pass a variable with includeJsFile?

Can you do something similar to using "with" in twig's include tag (http://twig.sensiolabs.org/doc/tags/include.html), but instead with includeJsFile? I am using a plugin to filter my entries by ...
3
votes
2answers
464 views

Access add and remove events with the Craft Element Selector?

Is there any way to access an event, and trigger some function, when an element is added / removed with the Craft Element Selector logic available in Garnish? I am working on a custom field type and ...
1
vote
1answer
615 views

How reference “Craft” js object in jquery scope

I have this function within my <script> tags: $('.btn').click(function() { var data = { title: "This is a title" }; Craft.postActionRequest('plugin/controller/action', data,...
2
votes
3answers
23k views

Can I set a JS variable to a Twig output tag?

This came out of a previous question I need to set a variable of a tag group that I can reference in jquery for use with a plugin. I'm declaring this variable in a tag so my included js files can ...
1
vote
1answer
1k views

Include Craft JS object

In the controller documentation for plugins, there's a section that talks about routing to specific actions using a Craft object like this: var url = Craft.getActionUrl('cocktailRecipes/ingredients/...
1
vote
0answers
131 views

How can I edit multiple entries via multiple front-end forms using Vue.js?

I found this post. However, writing a plugin in currently not an option, and I'd like to do this with Vue.js since I'm already using it for form validation & other stuff. Also, this involves ...
1
vote
1answer
84 views

Garnish event when changing category group

When I am on the categories index (admin/categories), is there a Garnish event that fires when you select a different category group in the sidebar? I want to add some custom JS after the AJAX request ...
1
vote
1answer
137 views

Detect task is finished

Is there a way to detect when a task is finished with js, for example I have a task running I can see the progress bar in the top right corner I would like to attach an event so when the task is done ...
1
vote
1answer
130 views

Element API - UrlHelper generates backwards slashes (regex)

I am generating a url within Element API: 'profile' => UrlHelper::getUrl("directory/company/{$member->id}/{$urlslug}"), which outputs: http:\/\/craft.fira\/directory\/company\/1501\/abet-...