From ae4d4d76aaf59c2b9ea74c357e58861725dea034 Mon Sep 17 00:00:00 2001
From: Subhodip Biswas
Date: Tue, 8 May 2012 10:18:34 +0530
Subject: [PATCH] List Items clickable Now
---
chaloBEST/static/js/buseditor.js | 81 +++++++++++++++++++++---------
chaloBEST/templates/buseditor.html | 20 ++++----
2 files changed, 67 insertions(+), 34 deletions(-)
diff --git a/chaloBEST/static/js/buseditor.js b/chaloBEST/static/js/buseditor.js
index fc496ec..b6166db 100644
--- a/chaloBEST/static/js/buseditor.js
+++ b/chaloBEST/static/js/buseditor.js
@@ -1,10 +1,10 @@
(function($) {
var API_BASE = 'http://chalobest.in/1.0/';
console.log(API_BASE);
- var testName = 'stops';
+ var clickedName = 'stops';
var searchQuery = 'None';
- var url1 = API_BASE + testName + '/' + '?q=';
- var url2 = API_BASE + testName + '/';
+ var url1 = API_BASE + clickedName + '/' + '?q=';
+ var url2 = API_BASE + clickedName + '/';
var Features = Backbone.Model.extend({});
var apiCollection = Backbone.Collection.extend({
@@ -16,44 +16,76 @@
});
var apiView = Backbone.View.extend({
- el: $('#sideBar'),
-
+ //el: '#sideBar',
+ events: {
+ "click a": "stopDetails"
+ },
initialize: function() {
-
+ //this.render();
_.bindAll(this, "render");
this.collection.bind("all", this.render);
//apiView.prototype.initialize.call(this);
},
render: function() {
- $(this.el).html(this.counter = this.collection.length);
+ //$(this.el).html(this.counter = this.collection.length);
console.log(this.collection.length);
+ //console.log(this.el);
this.collection.each( function(model){
- console.log(model.get('properties'));
- //alert(this.el);
- $('#sideBar').append("" + model.get('properties').official_name + "");
- //$('#sideBar').append("" + model.get('properties').area + "");
+ $('#sideBar').append(' ' + model.get('properties').official_name + "");
+ //console.log(model.cid);
});
+
+ return this;
+
+ },
+ clicked: function(e) {
+ //e.preventDefaults();
+ //var name1 = this.model.get('properties').official_name;
+ console.log(e);
+ //alert("you clicked me"+ e.target.innerHTML);
+
+
+ },
- //for(i=0; i< this.collection.length; i++) {
- // console.log(model.get('official_name')));
- // }
- // $(this.el).append("" + this.properties.official_name + "");
- // $(this.el).html(this.template(this.model.toJSON()));
- // $(this.el).html(this.counter = this.model.toJSON());
- return this;
- }
+ stopDetails: function(e) {
+ var cid = $(e.target).attr('id');
+ //this.trigger
+ //console.log(cid);
+ this.values= this.collection.getByCid(cid);
+ //this.trigger('new-stage', this.collection.get)
+ this.stopName = e.target.innerHTML;
+ //var test = this.collection.where({official_name: this.stopName});
+ console.log(this.values.get('properties').road);
+ $('#sLug').append(this.values.get('properties').slug);
+ $('#rOads').append(this.values.get('properties').road);
+ $('#rOutes').append(this.values.get('properties').routes);
+ $('#dIrection').append(this.values.get('properties').direction);
+ //console.log(e.target);
+ $('#dIsplayName').append(this.values.get('properties').official_name);
+ $('#mArathiName').append(this.values.get('properties').name_mr);
+ $('#aLtName').append(this.values.get('properties').alternative_names);
+ },
+ close:function () {
+ $(this.el).unbind();
+ $(this.el).remove();
+ }
+
}),
- events = new apiCollection(),
+ events = new apiCollection();
+ $(function() {
eventView = new apiView({
-
+ el: $("#sideBar"),
+ //el: $('#slug'),
+ //el:$('#displayName'),
collection: events
});
+
events.fetch({
success: function() {
console.log(events.length);
@@ -62,7 +94,7 @@
}
});
-
+});
@@ -100,6 +132,9 @@
//alert("I am here" + this.el);
});
-
+ //var router = Backbone.Router.extend({
+ //routes:{
+
+ //})
})(jQuery);
diff --git a/chaloBEST/templates/buseditor.html b/chaloBEST/templates/buseditor.html
index 75945b5..6895c6c 100644
--- a/chaloBEST/templates/buseditor.html
+++ b/chaloBEST/templates/buseditor.html
@@ -8,7 +8,7 @@
-
+
@@ -37,13 +37,14 @@
This BEST Bus stop editor allows you to edit Stops and Areas.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -54,7 +55,4 @@ This BEST Bus stop editor allows you to edit Stops and Areas.
-
-
-
{% endblock %}