These are chat archives for canjs/canjs

3rd
Mar 2015
Vojtech Prikryl
@Aldredcz
Mar 03 2015 13:17
Hello, I have a Component with helper being live-bound to scope attributes, and event catching same attributes and modifying them (before this modification, the scope state is in invalid state)... but the helper got resolved before the event,.. can I somehow prioritize the event callback, so the helper work with valid state?
Matthew Phillips
@matthewp
Mar 03 2015 13:19
hm, not sure i understand what you mean
Vojtech Prikryl
@Aldredcz
Mar 03 2015 13:21
inputType: function (subRule, options) {
                subRule = (typeof subRule === 'function') ? subRule() : subRule;

                var disabled = !subRule.attr('operator') || !subRule.attr('subject'),
                    multiple = disabled ? false : this.operatorsHash[subRule.attr('operator')].usage === 'STRING_LIST',
                    type;

                if (!this.predefinedValuesHash[subRule.attr('subject')] && multiple) {
                    type = 'tags';
                }
                else if (this.predefinedValuesHash[subRule.attr('subject')]) {
                    type = 'select';
                }
                else {
                    type = 'input';
                }

                return options.fn(options.scope.add({subRule: subRule, type: type, multiple: multiple, disabled: disabled}));
            }
{{#inputType .}}
                        {{#equals type 'input'}}
                            <input type="text" class="form-control" can-value="{subRule.value}" {{#if disabled}}disabled{{/if}}>
                        {{/equals}}
                        {{#equals type 'tags'}}
                            <div>
                                <input type="hidden" class="form-control" {{data 'input'}} {{initTags}}>
                            </div>
                        {{/equals}}
                        {{#equals type 'select'}}
                            <div>
                                <input type="hidden" class="form-control" {{data 'input'}} {{initSelect}}>
                            </div>
                            {{type}}, {{#if multiple}}multiple{{else}}single{{/if}}
                        {{/equals}}
                    {{/inputType}}
then I have events listening to changes in subRule.operator and subRule.subject, according to them, it modifies other attributes of subRule. And according to that, initTags and initSelect is rendered,.. but those helpers are called before event callbacks
Vojtech Prikryl
@Aldredcz
Mar 03 2015 14:05
already solved it ... had operator and subject bound by can-value on <select>, so changed it to can-change and handled all the changes in can.batch, so I'm always in valid state... but once I would need to react to changes from other controller and not from view,.. dunno how I would solve it..
Marshall Thompson
@marshallswain
Mar 03 2015 15:23
@matthewp Yes, still using 2.1.4, so can-compile’ing the views for a few more days.