Our EE Addons have Moved!
Our ExpressionEngine Add-ons have been acquired by EE Harbor. Head over there for documentation, info and support.
Our ExpressionEngine Add-ons have been acquired by EE Harbor. Head over there for documentation, info and support.
All the action urls in shortlist can be called via ajax. If shortlist detects the call is being made via ajax it will return a json array of the result instead of redirecting the user.
Note: The following examples assume the use of jQuery as the js library in place. The same processes will work with any js library with basic syntax changes.
The first step is to attach your event handlers to your anchors. In these examples we've simply added a class of 'shortlist_action' to the anchors. For convenience we've also added a wrapper class of 'shortlist_action_container' to the surrounding markup.
<div class="shortlist_action_container"> <a href="{add_url}" class="shortlist_action">+ to shortlist</a> </div>
Then in our js :
$('a.shortlist_action').on('click',function(){ parent = $(this).parent('.shortlist_action_container'); $.ajax({ url: $(this).attr('href'), success: function(data) { // Do something with the result verb = data['verb']; total_items = data['total_items']; // .. } }); // stop event propagation here return false; });
When calling an action url the following values are returned (for use in the data array) :
type
list_items
total_items
toggle_url
Note: If the action performed was a whole list clone, the return value will be a blank string
verb