search foo

This commit is contained in:
Sanj 2011-09-28 22:18:29 +05:30
parent a0a0992854
commit 222e8fd489
4 changed files with 12 additions and 7 deletions

View File

@ -5,6 +5,7 @@ from django.contrib.contenttypes.models import ContentType
class Module(models.Model):
title = models.CharField(max_length=255, help_text="Title of Module. eg. Best Practices")
slug = models.SlugField(help_text="short name of module to be used for url. eg. bestpractices")
about = models.TextField(blank=True)
def __unicode__(self):
return self.title

View File

@ -44,7 +44,7 @@ def get_list(request):
'search': request.GET.get("search", ""),
'sort': sortArray,
'page': request.GET.get("page", 1),
# 'count': request.GET.get("count", 12) #FIXME: make list_length either in settings.py or config per model
'count': request.GET.get("count", 12) #FIXME: make list_length either in settings.py or config per model
}
object_list = tab.get_list(list_options)
return render_to_json_response(object_list)

View File

@ -117,22 +117,24 @@ $(function() {
});
$('#orderBySelect').change(function(e) {
$('.selectMenu').submit();
$('#listForm').submit();
});
$('#searchListIcon').click(function() {
$('.selectMenu').submit();
$('#listForm').submit();
});
/*
$('.searchListField').keyup(function(e) {
e.preventDefault();
if (e.keyCode == 13) {
$('.selectMenu').submit();
$('#listForm').submit();
}
});
*/
$('.selectMenu').submit(function(e) {
$('#listForm').submit(function(e) {
e.preventDefault();
var sortString = $('#orderBySelect').val();
var searchTerm = $('.searchListField').val();
@ -167,8 +169,8 @@ function displayList(items) {
}
function doListLoading() {
$('#loadingList').show();
$('.tabListItem').remove();
$('#loadingList').show();
}
function stopListLoading(page) {
@ -223,6 +225,7 @@ function getNoListHtml(items) {
return $rhs;
}
function getNoListItemHtml(item) {
if (item.hasOwnProperty("url")) {
var $ret = $('<div />').addClass("noListItem");
@ -237,6 +240,7 @@ function getNoListItemHtml(item) {
return $ret;
}
jQuery.fn.formatTitle = function() {
var txt = $(this).text();
var fontSize;

View File

@ -50,7 +50,7 @@
{{ t.text }}
</div>
{% endfor %}
<!--is this select okay, my forms are a bit weak, do we need action and method here?--><form class="selectMenu" action="" method="post">
<!--is this select okay, my forms are a bit weak, do we need action and method here?--><form class="selectMenu" id="listForm" method="post" action="">
<span>Order by</span><!--Can i avoid a p tag here to keep it inline-->
<select id="orderBySelect">Select
{% for s in default_sorts %}