Stop editor form field visible on click

This commit is contained in:
Subhodip Biswas 2012-05-10 16:16:27 +05:30
parent 413896befa
commit 32592cbfa4

View File

@ -1,11 +1,14 @@
(function($) { (function($) {
var API_BASE = 'http://chalobest.in/1.0/'; var API_BASE = 'http://localhost:8000/1.0/';
console.log(API_BASE); console.log(API_BASE);
var clickedName = 'stops'; var clickedName = 'stops';
var searchQuery = 'None'; var searchQuery = 'None';
var url1 = API_BASE + clickedName + '/' + '?q='; var url1 = API_BASE + clickedName + '/' + '?q=';
var url2 = API_BASE + clickedName + '/'; var url2 = API_BASE + clickedName + '/';
var Features = Backbone.Model.extend({}); var Features = Backbone.Model.extend({
});
var apiCollection = Backbone.Collection.extend({ var apiCollection = Backbone.Collection.extend({
model: Features, model: Features,
@ -15,26 +18,26 @@
} }
}); });
var apiView = Backbone.View.extend({ var apiView = Backbone.View.extend({
//el: '#sideBar', //el: '#content',
events: { events: {
"click a": "stopDetails" "click a": "clicked"
}, },
initialize: function() { initialize: function() {
//this.render(); //this.render();
_.bindAll(this, "render"); _.bindAll(this, "render", "clicked");
this.collection.bind("all", this.render); this.collection.bind("all", this.render, this.clicked);
//apiView.prototype.initialize.call(this); //apiView.prototype.initialize.call(this);
}, },
render: function() { 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.collection.length);
//console.log(this.el); //console.log(this.el);
this.collection.each(function(model) { this.collection.each(function(model) {
$('#sideBar').append('<li> <a id=\'' + model.cid + '\' href="#">' + model.get('properties').official_name + "</a></li>"); $('#sideBar').append('<li> <a id=\'' + model.cid + '\' href="#">' + model.get('properties').official_name + "</a></li>");
//console.log(model.cid); //console.log(model.cid);
}); });
return this; return this;
@ -43,15 +46,34 @@
clicked: function(e) { clicked: function(e) {
//e.preventDefaults(); //e.preventDefaults();
//var name1 = this.model.get('properties').official_name; //var name1 = this.model.get('properties').official_name;
console.log(e);
//console.log(e);
//alert("you clicked me"+ e.target.innerHTML); //alert("you clicked me"+ e.target.innerHTML);
events.trigger('stopdetailsEvent', e);
//return this;
}, },
//close: function() {
// $(this.el).unbind();
// $(this.el).remove();
//}
});
var stopView = Backbone.View.extend({
el: '#content',
initialize: function() {
_.bindAll(this, "stopDetails");
this.collection.bind("stopdetailsEvent", this.stopDetails);
},
stopDetails: function(e) { stopDetails: function(e) {
//console.log(e);
//alert("you clicked me"+ e.target.innerHTML);
var cid = $(e.target).attr('id'); var cid = $(e.target).attr('id');
//this.trigger //this.trigger
//console.log(cid); //console.log(cid);
@ -59,25 +81,28 @@
//this.trigger('new-stage', this.collection.get) //this.trigger('new-stage', this.collection.get)
this.stopName = e.target.innerHTML; this.stopName = e.target.innerHTML;
//var test = this.collection.where({official_name: this.stopName}); //var test = this.collection.where({official_name: this.stopName});
console.log(this.values.get('properties').road); //console.log(this.values.get('properties').road);
$('#sLug').append(this.values.get('properties').slug); //console.log(this.el);
$('#rOads').append(this.values.get('properties').road); $(this.el).find('input#sLug').val(this.values.get('properties').slug);
$('#rOutes').append(this.values.get('properties').routes); //$('#sLug').attr('id', 'sLug').value(this.values.get('properties').slug);
$('#dIrection').append(this.values.get('properties').direction); $(this.el).find('input#rOads').val(this.values.get('properties').road);
$(this.el).find('textarea#rOutes').html(this.values.get('properties').routes);
$(this.el).find('input#dIrection').val(this.values.get('properties').direction);
//console.log(e.target); //console.log(e.target);
$('#dIsplayName').append(this.values.get('properties').official_name); $(this.el).find('input#dIsplayName').val(this.values.get('properties').official_name);
$('#mArathiName').append(this.values.get('properties').name_mr); $(this.el).find('input#mArathiName').val(this.values.get('properties').name_mr);
$('#aLtName').append(this.values.get('properties').alternative_names); $(this.el).find('input#aLtName').val(this.values.get('properties').alternative_names);
}, },
close:function () { });
$(this.el).unbind();
$(this.el).remove();
}
}),
events = new apiCollection(); events = new apiCollection();
$(function() { $(function() {
stopDetailsView = new stopView({
el: $("#content"),
collection: events
});
eventView = new apiView({ eventView = new apiView({
el: $("#sideBar"), el: $("#sideBar"),
//el: $('#slug'), //el: $('#slug'),
@ -86,12 +111,12 @@
}); });
events.fetch({ events.fetch({
success: function() { success: function() {
console.log(events.length); console.log(events.length);
//console.log(this.official_name); //console.log(this.official_name);
//alert(); //alert();
} }
}); });
}); });
@ -134,7 +159,5 @@
//var router = Backbone.Router.extend({ //var router = Backbone.Router.extend({
//routes:{ //routes:{
//}) //})
})(jQuery); })(jQuery);