summaryrefslogtreecommitdiff
path: root/modules/tag/js
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-27 05:37:20 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-27 05:37:20 +0000
commit72d16756b169e1f751470670eececf76e88b2bd7 (patch)
tree7e49f000e23a7ae54c69d081f264bc378903a0d3 /modules/tag/js
parent5447b8321080afd09387d837a4acfa9c90ddfa16 (diff)
Refactor cloud generation into a helper so that we can call it from
Tags_Controller::_index(). This enables our Ajax code to reload the tags block after we submit a new tag, so update the JS to do that properly.
Diffstat (limited to 'modules/tag/js')
-rw-r--r--modules/tag/js/tag.js26
1 files changed, 12 insertions, 14 deletions
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index 30e9ca50..fbcbd419 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -1,19 +1,17 @@
$("document").ready(function() {
- var options = {
- target: "#gTagFormContainer",
- success: function(responseText, statusText) {
- $("#gAddTag").ajaxForm(options);
- }
- };
- $("#gAddTag").ajaxForm(options);
+ ajaxify_tag_form();
});
-function get_tag_block(url) {
- $.post(url, function(data) {
- $('#gTagFormContainer').html(data);
- $("#gAddTag").submit(function(event){
- get_tag_block($("#gAddTag").attr("action"));
- return false;
- });
+function ajaxify_tag_form() {
+ $("form#gAddTag").ajaxForm({
+ complete: function(xhr, statusText) {
+ $("form#gAddTag").replaceWith(xhr.responseText);
+ if (xhr.status == 201) {
+ $.get($("#gTagCloud").attr("src"), function(data, textStatus) {
+ $("#gTagCloud").html(data);
+ });
+ }
+ ajaxify_tag_form();
+ }
});
}