ember.js - Ember.handlebars boundIf didn't call calculated property -
i try migrate project form ember cli 0.1.2 0.1.15. current problem next:
i have can-helper. works fine @ older ember @ newer version can-blocks absent. can-helper use calculated property in model, try set debugger calculation function - work on 0.1.2 , didn't work @ 0.1.15
original ember - 1.7.0-beta.1 try migrate ember - 1.9.1
as found implementation of boundif helper changed. have ideas / experience such trouble?
p.s. code of can-helper below
var = ember.get, isglobalpath = ember.isglobalpath, normalizepath = ember.handlebars.normalizepath, is_binding = ember.is_binding; var getprop = function(context, property, options) { if (isglobalpath(property)) { return get(property); } else { var path = normalizepath(context, property, options.data); return get(path.root, path.path); } }; export default function(permissionname, property, options) { var attrs, context, key, path, permission; // property optional, if we've got 2 arguments property contains our options if (!options) { options = property; property = null; } context = (options.contexts && options.contexts[0]) || this; attrs = {}; // if we've got property name, value , set permission's content // set passed in `post` content eg: // {{#can editpost post}} ... {{/can}} if (property) { attrs.content = getprop(context, property, options); } // if we've got options, find values eg: // {{#can createpost project=project user=app.currentuser}} ... {{/can}} (key in options.hash) { if (!options.hash.hasownproperty(key)) { continue; } path = options.hash[key]; if (options.hashtypes[key] === 'string') { if (is_binding.test(key)) { attrs[key.slice(0, -7)] = getprop(context, path, options); } else { attrs[key] = path; } } else { attrs[key] = getprop(context, path, options); } } // find & create permission supplied attributes permission = this.get('container').lookup('permissions:main').get(permissionname, attrs); // ensure boundif uses permission context , not view/controller // otherwise looks 'can' in wrong place options.contexts = null; // bind , kickoff observers return ember.handlebars.helpers.boundif.call(permission, "can", options); }
in template used as
{{#can read model="contact"}} <div class="panel"> {{#link-to 'contacts' id="nav-to-contacts" class="main-menu-root-item" title="contacts"}} contacts {{/link-to}} </div> {{/can}}
can computed property @ permission
can: function() { var model = get(this, 'model'), field = get(this, 'field'), permission = rules.findby('name', model); return permission && permission.read && (field ? permission.read.contains(field) : permission.read.length); }.property()
at older version can stop inside debugger statement, after updating - can't it's possible errors on observers changes of model, should called @ least once ( on initial rendering ) - understand
the reason in wrong context getting property please here https://github.com/emberjs/ember.js/issues/10692
Comments
Post a Comment