Login

Add extra form elements in your contib admin

Author:
sergejdergatsjev
Posted:
November 28, 2008
Language:
JavaScript
Version:
Not specified
Score:
0 (after 0 ratings)

Add extra form elements in your contib admin

Install

add this in header of base.html

<script type="text/javascript" src="/static/jquery-1.2.6.min.js"></script>

http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js

 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
function createElement(parent, id){
    template = "<div class=\"filter\" id=\"filter\"><fieldset><legend>Send to filter</legend><select id=\"select" + id +
        "\"></select><a class=\"addlink\" id=\"button"   + id + 
        "\">SEND</a>&nbsp;&nbsp;&nbsp;<span  id=\"out" + id  +
        "\"></span></fieldset></div>";
    $(template).appendTo(parent);
    $("#select" + id).load("/filter/options/ #options option");
    
}

function attachEvents(id){
    $("#button" +  id).bind("click", function(e){
      	    var url = $("#select" + id + " option:selected").val();		
	                                      
                $.post("/send/", { "filter": url, "message": id},
                    function(data){
                        $("#out" + id).text(data).fadeIn(3000);
			$("#out" + id).text(data).fadeOut(3000);								
                    });
								
    });

}
 

function AddSenders(){
    $(".row1").each(function(i){
        var url = $(this).find("th").find("a").attr("href");
        var url = url.replace(/\//, "");        
        createElement($(this).find("th"), url);
        attachEvents(url);
     });

    $(".row2").each(function(i){
        var url = $(this).find("th").find("a").attr("href");
        var url = url.replace(/\//, "");       
        createElement($(this).find("th"), url);
        attachEvents(url);    
     });
}

 $(document).ready(function() {
	//do stuff when DOM is ready jQury     

    if(jQuery.url.attr("path") == "/admin/org/message/")AddSenders();
		
 });

More like this

  1. Django Collapsed Stacked Inlines by applecat 1 year, 1 month ago
  2. Django Collapsed Stacked Inlines by mkarajohn 3 years, 2 months ago
  3. Dynamically adding forms to a formset. OOP version. by halfnibble 8 years, 10 months ago
  4. Convert multiple select for m2m to multiple checkboxes in django admin form by abidibo 10 years, 11 months ago
  5. Django admin inline ordering - javascript only implementation by ojhilt 11 years, 3 months ago

Comments

Please login first before commenting.