From 18291cd9ef9a6b7d3f13aa08b65f64dd430d10b3 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 13 Jan 2012 01:33:41 +0530 Subject: [PATCH] object_id weirdoness fixed. --- itf/insidepages/views.py | 6 +++--- itf/static/js/insidepage.js | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/itf/insidepages/views.py b/itf/insidepages/views.py index 3cd37bb..390a8f3 100755 --- a/itf/insidepages/views.py +++ b/itf/insidepages/views.py @@ -2,7 +2,7 @@ from models import Module, ModuleTab from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from ox.django.shortcuts import render_to_json_response - +import re def main(request, module_slug): m = get_object_or_404(Module, slug=module_slug) @@ -40,11 +40,11 @@ def get_tab(request): def get_list(request): + numre = re.compile("[0-9]*") tab_slug = request.GET.get("tab", "") tab = get_object_or_404(ModuleTab, slug=tab_slug) object_id = request.GET.get("object_id", False) - if object_id.find("#") != -1: - object_id = object_id[0:object_id.find("#")] #FIXME - why is the front-end sending this? + object_id = object_id[numre.match(object_id).start():numre.match(object_id).end()] #FIXME - why is the front-end sending this? sortString = request.GET.get("sort", "") if sortString == "" or sortString == 'null': sortArray = [] diff --git a/itf/static/js/insidepage.js b/itf/static/js/insidepage.js index d33d6bf..731380e 100755 --- a/itf/static/js/insidepage.js +++ b/itf/static/js/insidepage.js @@ -1,4 +1,4 @@ -var queryData; +var queryData; //will store initial query data as a global var for submodule js to potentially use $('.toggleBtn').live("click", function() { var $this = $(this); @@ -10,7 +10,6 @@ $('.toggleBtn').live("click", function() { } }); - $('#listLeft ul li a').live("click", function() { if ($(this).hasClass("listLeftSelected")) { return false; @@ -399,7 +398,7 @@ function displayList(items) { if (state.object_id == undefined || state.object_id == '') { $('#listLeft ul li a').eq(0).click(); } else { - var $a = $('#listLeft ul li a[data-id=' + state.object_id + ']'); + var $a = $('#listLeft ul li a[data-id=' + parseInt(state.object_id) + ']'); if ($a.length > 0) { $a.click(); } else {