Skip to content

Commit

Permalink
Adding new "ignore" case for ajax responses. Renaming Ajax to ajax.
Browse files Browse the repository at this point in the history
  • Loading branch information
anutron committed Mar 7, 2014
1 parent b468060 commit d9c61a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Docs/Delegators/Delegator.Ajax.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Delegator Trigger: Ajax
Delegator Trigger: ajax
=======================

Loads the response of a link's URL into a specified target.

### Example

<a href="/get/list/item.php"
data-trigger="Ajax"
data-trigger="ajax"
data-ajax-options="
'action': 'injectBottom',
'target': '!body ul'
Expand Down Expand Up @@ -39,6 +39,7 @@ The above example will load the response from the links HREF (`get/list/item.php
* `injectBottom` - inserts the response at the bottom of the target after any of it's other children.
* `injectBefore` - inserts the response before the target.
* `injectAfter` - inserts the response after the target.
* `ignore` - response is discarded.

### Notes

Expand Down
10 changes: 8 additions & 2 deletions Source/Delegators/Delegator.Ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Delegator.Ajax
(function(){
var send = function(event, link, api){
if (api.getAs(Boolean, 'loadOnce') === true && link.retrieve('ajaxLoaded')){
api.warn('already loaded link via ajax. `once` option is true, so exiting quietly.');
api.warn('already loaded link via ajax. `once` option is true, so exiting quietly.', api.get('href') || link.get('href'));
return;
}
var target,
Expand Down Expand Up @@ -54,6 +54,8 @@ name: Delegator.Ajax
elements = new Element('div').adopt(elements).getElements(api.get('filter'));
}
switch(action){
case 'ignore':
break;
case 'replace':
var container = target.getParent();
elements.reverse().inject(target , 'after');
Expand Down Expand Up @@ -100,7 +102,7 @@ name: Delegator.Ajax
link.store('ajaxLoaded', true);
};

Delegator.register('click', 'Ajax', {
Delegator.register('click', 'ajax', {
require: ['target'],
defaults: {
action: 'injectBottom',
Expand All @@ -124,4 +126,8 @@ name: Delegator.Ajax
}
});

// legacy

Delegator.cloneTrigger('ajax', 'Ajax');

})();

0 comments on commit d9c61a2

Please sign in to comment.