works on local, testing

This commit is contained in:
Sanj 2011-06-29 22:44:27 +05:30
parent 58ad185e04
commit fb67606ba7
2 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,10 @@ $(function() {
$('#filterForm').submit(function(e) { $('#filterForm').submit(function(e) {
e.preventDefault(); e.preventDefault();
var formData = $(this).serializeArray(); var formData = $(this).serializeArray();
$('#submitFilter').val("Loading...").attr("disabled", "disabled");
$.post("files/json_list", formData, function(response) { $.post("files/json_list", formData, function(response) {
$('#submitFilter').val("Submit").removeAttr("disabled");
// MAAKICHUT = response;
var data = JSON.parse(response); var data = JSON.parse(response);
var files = data.files; var files = data.files;
// console.log(files); // console.log(files);
@ -19,13 +22,16 @@ $(function() {
function getJQ(f) { function getJQ(f) {
var jq = $("<div />").data("data", f).addClass("fileItem").text(f.type + ": " + f.title); var jq = $("<div />").data("data", f).addClass("fileItem").text(f.type + ": " + f.title);
jq.click(function() { jq.click(function() {
var d = $(this).data("data"); var $this = $(this);
$('.selectedItem').removeClass("selectedItem");
$this.addClass("selectedItem");
var d = $this.data("data");
switch (d.type) { switch (d.type) {
case "image": case "image":
var html = "<img src='" + d.url + "' />"; var html = "<img width='400' src='" + d.url + "' />";
break; break;
default: default:
var html = "<a href='" + d.url + "'>Click to view</a>"; var html = "<a href='" + d.url + "' target='_blank'>Click to view</a>";
} }
$('#previewPane').html(html); $('#previewPane').html(html);
}); });

View File

@ -11,7 +11,7 @@
<form id="filterForm"> <form id="filterForm">
{{ filterForm.as_p }} {{ filterForm.as_p }}
<p> <p>
<input type="submit" value="Submit" /> <input type="submit" value="Submit" id="submitFilter" />
</p> </p>
</form> </form>
</div> </div>