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