github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

husio / tutorials

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2
    • 0
  • Source
  • Commits
  • Network (0)
  • Downloads (2)
  • Graphs
  • Tree: bbcba41

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (2)
    • django_blog_with_ajax
    • django_blog_no_ajax
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Source code for tutorials. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

django blog w wersji z ajax. 
Piotr Husiatyński (author)
Mon Aug 17 13:03:22 -0700 2009
commit  bbcba414e706fd7a135377ec00c3d15a90808eaf
tree    83b805f51ac9faa57a5ad18b03072c6e8105f6ea
parent  5862e2a0144d568b4b918e486fbba58af0dff7ba
tutorials / ajax / mywebsite / statics / javascript / ajax_comments.js ajax/mywebsite/statics/javascript/ajax_comments.js
100644 68 lines (56 sloc) 1.796 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const COMMENT_FORM_URL = 'form/'
const COMMENT_POST_URL = '.'
const COMMENT_PREVIEW_URL = 'preview/'
 
 
function getFormData() {
    var formData = {}
    $('#comment\-form').find(':input, :text').each(function() {
        var formName = $(this).attr('name');
        formData[formName] = $(this).val();
    });
    return formData;
}
 
function submitFormCallback(response) {
    if (response.status == 'ok') {
        $('#comments\-box').append(response.comment);
        $('#comment\-form').fadeOut('slow', function() { $(this).remove() });
    } else if (response.status == 'fail') {
        $('#comment\-form').html(response.form);
        $('#comment\-form :submit').click(submitForm);
    } else {
        // server error?
    };
};
 
 
function showCommentForm(commentForm) {
    $('#comment\-form').html(commentForm);
    $('#comment\-form :submit').click(submitForm);
    $('#comment\-form :submit:last').after(
            '<input id="form-submit-preview" type="submit" value="Podgląd"/>')
    $('#form\-submit\-preview').click(previewSubmit);
};
 
function getCommentFormCallback(response) {
    if (response.status == "ok")
        showCommentForm(response.form);
    // else.. well, fail
};
 
function previewSubmitCallback(response) {
    if (response.status == 'ok') {
        $('#comment-preview').html(response.comment);
    } else {
        // fail
    }
}
 
function previewSubmit() {
    var postData =
    $.post(COMMENT_PREVIEW_URL, getFormData(), previewSubmitCallback, 'json');
    return false;
};
 
function submitForm() {
    $.post(COMMENT_POST_URL, getFormData(), submitFormCallback, 'json');
    return false;
};
 
function getCommentForm() {
    $.get(COMMENT_FORM_URL, {}, getCommentFormCallback, 'json');
};
 
$(document).ready(function() {
    getCommentForm();
});
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server