Skip to content

Commit

Permalink
add bdajax.fiddle function
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Apr 28, 2011
1 parent e0bbdfa commit 42e8364
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,11 @@ Contributors
Changes
=======

1.2dev
------
1.2
---

- add ``bdajax.fiddle`` function.
[rnix, 2011-04-28]

- delete overlay data from DOM element before reinitializing.
[rnix, 2011-04-21]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os

version = '1.2dev'
version = '1.2'
shortdesc = 'Ajax convenience.'
longdesc = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
longdesc += open(os.path.join(os.path.dirname(__file__), 'LICENSE.rst')).read()
Expand Down
30 changes: 16 additions & 14 deletions src/bdajax/resources/bdajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,28 @@
bdajax.error('Empty response');
bdajax.spinner.hide();
} else {
var mode = data.mode;
var selector = data.selector;
if (mode == 'replace') {
$(selector).replaceWith(data.payload);
var context = $(selector);
if (context.length) {
context.parent().bdajax();
} else {
$(document).bdajax();
}
} else if (mode == 'inner') {
$(selector).html(data.payload);
$(selector).bdajax();
}
bdajax.fiddle(data.payload, data.selector, data.mode);
bdajax.continuation(data.continuation);
}
}
});
},

fiddle: function(payload, selector, mode) {
if (mode == 'replace') {
$(selector).replaceWith(payload);
var context = $(selector);
if (context.length) {
context.parent().bdajax();
} else {
$(document).bdajax();
}
} else if (mode == 'inner') {
$(selector).html(payload);
$(selector).bdajax();
}
},

continuation: function(definitions) {
if (!definitions) {
return;
Expand Down
3 changes: 1 addition & 2 deletions src/bdajax/resources/bdajax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 42e8364

Please sign in to comment.