Add extra form elements in your contib admin

 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. Add special field lookups to the Admin list_filter display by whiteinge 6 years, 2 months ago
  2. Dynamically add inlines by MasonM 4 years, 10 months ago
  3. Unobtrusvie Foldable Admin Interface by whiteinge 6 years, 3 months ago
  4. Collapsed stacked inlines by Aneon 4 years, 11 months ago
  5. Confirm alert if the user navigates away without saving changes by mrazzari 4 years, 9 months ago

Comments

(Forgotten your password?)