some fixes on search filter for areas and routes views

This commit is contained in:
Sanj 2012-02-16 19:29:33 +05:30
parent 7e4dd89b4a
commit cd295a2511
3 changed files with 11 additions and 8 deletions

View File

@ -124,6 +124,9 @@ class Route(models.Model):
distance = models.DecimalField(max_digits=3, decimal_places=1) distance = models.DecimalField(max_digits=3, decimal_places=1)
stages = models.IntegerField() stages = models.IntegerField()
def get_absolute_url(self):
return "/route/%s/" % self.alias
def __unicode__(self): def __unicode__(self):
return self.alias return self.alias

View File

@ -7,9 +7,9 @@
{% block head %} {% block head %}
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('#searchRoutes').change(function() { $('#searchFilter').change(function() {
var val = $(this).val().toLowerCase(); var val = $(this).val().toLowerCase();
$('.area').each(function() { $('.listItem').each(function() {
var txt = $(this).text().toLowerCase(); var txt = $(this).text().toLowerCase();
if (txt.indexOf(val) != -1) { if (txt.indexOf(val) != -1) {
$(this).show(); $(this).show();
@ -24,10 +24,10 @@ $(function() {
{% endblock %} {% endblock %}
{% block body %} {% block body %}
Filter: <input id="searchRoutes" /> Filter: <input id="searchFilter" />
<ul id="routesList"> <ul id="routesList">
{% for a in areas %} {% for a in areas %}
<li class="route"> <li class="area listItem">
<a href="{{ a.get_absolute_url }}" title="view stops for route">{{ a.name }}</a> <a href="{{ a.get_absolute_url }}" title="view stops for route">{{ a.name }}</a>
</li> </li>
{% endfor %} {% endfor %}

View File

@ -7,9 +7,9 @@
{% block head %} {% block head %}
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('#searchRoutes').change(function() { $('#searchFilter').change(function() {
var val = $(this).val().toLowerCase(); var val = $(this).val().toLowerCase();
$('.route').each(function() { $('.listItem').each(function() {
var txt = $(this).text().toLowerCase(); var txt = $(this).text().toLowerCase();
if (txt.indexOf(val) != -1) { if (txt.indexOf(val) != -1) {
$(this).show(); $(this).show();
@ -27,8 +27,8 @@ $(function() {
Filter: <input id="searchRoutes" /> Filter: <input id="searchRoutes" />
<ul id="routesList"> <ul id="routesList">
{% for r in routes %} {% for r in routes %}
<li class="route"> <li class="route listItem">
<a href="/route/{{r.alias}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }} <a href="{{r.get_absolute_url}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>