Giter VIP home page Giter VIP logo

Comments (3)

ecbypi avatar ecbypi commented on June 16, 2024

Hi @AjayBarot-BTC, I'm not immediately aware why this would be an issue with CompositeView or Backbone.View. Could you provide more context as to how you're reloading model data within a CompositeView or what method fails such that you have to reload the page? The gist you provided isn't super helpful since it's a lot of code to grok and I can't immediately separate domain logic from behavior.

from backbone-support.

AjayBarot avatar AjayBarot commented on June 16, 2024

@ecbypi Thanks for a quick reply .
Let me explain the problem in detail
router
({
editItem: function(itemId) {
var assetView, item;
item = this.homeMenu.getItem(itemId);
assetView = ActivityView.create(item.get("activity_type"), {
groups: this.groups,
people: this.people
});
return this.swap(new EditItemView({
model: item,
activityView: assetView,
roles: this.roles,
tags: this.tags,
globalStockImages: this.globalStockImages,
groups: this.groups
}));
}
});

activity_view
this.ActivityView = new PolymorphicFactory("activity view");

polymorphicFactory

edit_item_view

Now in item_form asset activity view called by this function
({
renderActivityView: function() {
this.activityView.model = this.model.activity;
this.renderChild(this.activityView);
this.activityView.bind("loading", this.loading, this);
this.activityView.bind("change", this.changeActivity, this);
return this.$(".activity_fields").append(this.activityView.el);
}
});
and submit saved functions are triggered from here

Now in content/activity_view/asset.js
Here I show two check box and configure link as given in image
link
here I am saving model data by using serialize method :
({
serialize: function() {
return $.extend(this.attributes, {
base_module_ids: this.$('#base_module_ids').val()
});
}
});
Here is my as_json method in model asset.rb
if base_modules
modules_array = []
base_modules.each do |base_module|
modules = {}
modules[:base_module_id] = base_module.id
modules[:modulable_type] = base_module.modulable_type
modules_array << modules end
result[:base_module_ids] = modules_array
end result

everything is working expect update base_module scenario
Following is the this.model log after save

log

After reload (refresh window) base_module_ids shown as a object
Following is the this.model log after refresh window

log2
By reload page we can solved this issue but its taking too much time to reload page in production so we have to improve this.

We are using backbone-on-rails (1.0.0.0) and backbone-support (0.4.0)

You can see whole asset.js (content/activity_view/asset.js) for reference
asset.js

Please tell me if you don't get anything from above code or anything.
Thanks for your support

Thanks & Regards
Ajay Barot

from backbone-support.

ecbypi avatar ecbypi commented on June 16, 2024

Hi @AjayBarot-BTC, the additional code doesn't help me see why CompositeView would prevent Model#sync(), Model#fetch() or any other means of updating a model or collection from behaving correctly.

Could you provide a simplified, reproducible example of the problem independent of the business logic of your app?

from backbone-support.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.