मैं या तो बड़े पैमाने पर थक गया हूं या वास्तव में उलझन में हूं ... लेकिन मुझे यकीन नहीं है ... मेरे पास एक parse.com जावास्क्रिप्ट सेटअप है (यह रीढ़ की हड्डी के बजाय पार्स के साथ बिल्कुल बैकबोन.जेएस की तरह है)। और मेरे पास एक मॉडल है, और एक संग्रह है, और यह सब काम करता है। लेकिन डर्न टू जेसन(); काम नहीं करता है, यह सिर्फ [] में console.log में देता है ... हालांकि अगर मैं क्रोमस कंसोल में एक ही फ़ंक्शन चलाता हूं तो यह सही मानों को काम करता है और देता है।बैकबोन toJSON
कोई मदद !?
सभी इस सुंदर कोड एक दस्तावेज तैयार में लपेटा जाता है (और यह कुछ अन्य कोड जो प्रासंगिक नहीं है था और हाँ मैं Parse.initialize()
'है यह d।
var Schedule = Parse.Object.extend({
className: "schedule"
});
var ScheduleList = Parse.Collection.extend({
model: Schedule
});
schedule = new ScheduleList();
schedulejs3 = schedule.toJSON();
schedule.query = new Parse.Query(Schedule);
schedule.query.ascending("date");
schedule.query.limit('500');
schedulejs2 = schedule.toJSON();
schedule.fetch();
schedulejs = schedule.toJSON();
console.log(schedulejs,schedulejs2,schedulejs3); <-- All three return []
var ScheduleView = Parse.View.extend({
el: $("#schedule-holder"),
initialize: function() {
this.schedule = new ScheduleList();
this.schedule.query = new Parse.Query(Schedule);
this.schedule.query.ascending("date");
this.schedule.query.limit('500');
this.schedule.fetch();
this.schedule.js = this.schedule.toJSON();
this.render;
},
render: function() {
var template = Handlebars.compile($("#schedule-item").html());
$(this.el).html(template({shows: this.schedule.toJSON()}));
return this;
}
});
var App = new ScheduleView().render();
लेकिन अगर मैं क्रोम और समय में कंसोल खोलें schedule.toJSON(); मुझे सही मान मिलते हैं ... जैसा कि आप देख सकते हैं कि मैंने अपनी बैकबोन.जेएस सेटअप को इस तरह से समझने की कोशिश की है (आप सोच रहे हैं कि सब कुछ जगह पर क्यों है)। और थोड़ा नोट, मैं Zepto.js का उपयोग नहीं कर रहा हूं jQuery।
धन्यवाद!