Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:28
    greenkeeper[bot] commented #5392
  • 05:28

    greenkeeper[bot] on core-js-3.4.1

    chore(package): update core-js … (compare)

  • Nov 11 18:03
    greenkeeper[bot] labeled #5422
  • Nov 11 18:03
    greenkeeper[bot] opened #5422
  • Nov 11 18:03

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Nov 11 18:02
    greenkeeper[bot] commented #5401
  • Nov 11 18:02

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Nov 10 23:39

    greenkeeper[bot] on @octokit

    (compare)

  • Nov 10 23:37

    greenkeeper[bot] on @octokit

    chore(package): update @octokit… (compare)

  • Nov 08 16:08
    greenkeeper[bot] labeled #5421
  • Nov 08 16:08
    greenkeeper[bot] opened #5421
  • Nov 08 16:08

    greenkeeper[bot] on can-stache-bindings-5.0.2

    fix(package): update can-stache… (compare)

  • Nov 07 17:31

    cherifGsoul on 6-2-5-version

    (compare)

  • Nov 07 17:31
    cherifGsoul closed #5420
  • Nov 07 17:30

    cherifGsoul on master

    Update dist for release (compare)

  • Nov 07 17:28
    cherifGsoul edited as member
  • Nov 07 17:27
    cherifGsoul added as member
  • Nov 07 17:17
    cherifGsoul opened #5420
  • Nov 07 17:17

    cherifGsoul on 6-2-5-version

    Bump Version I don't have push… (compare)

  • Nov 07 17:09

    cherifGsoul on v6.2.5

    Update dist for release 6.2.5 (compare)

Chris Gomez
@akagomez
Yeah, in your view model.
(or scope if you haven’t made the change)
opolyo01
@opolyo01
Thanks, it works. Now I need to add "change, blur" on top of keyUp event and I am all set
Chris Gomez
@akagomez
Great! In the meantime, I put together this demo: http://jsbin.com/vusuzu/1/edit?js,console
I'm currently working on a much easier way to derive a bound, filtered list from another, so stay tuned: https://github.com/canjs/can-derive
opolyo01
@opolyo01
pretty useful
opolyo01
@opolyo01
Is it the correct way defining the same handler for multiple events
'.search-dimension keyup': this.searchTermChanged,
'.search-dimension change': this.searchTermChanged,
'.search-dimension blur': this.searchTermChanged,
        searchTermChanged: function(el, ev){
            var searchTerm = el.val();
            this.scope.attr('searchTerm', searchTerm);
        },
somehow it only works only if I do -- '.search-dimension keyup': function(el, ev)
Chris Gomez
@akagomez
@opolyo01 'el event
Whoops…
’el event’: ‘handler’
opolyo01
@opolyo01
nice
'.search-dimension keyup': 'searchTermChanged',
'.search-dimension change': 'searchTermChanged',
'.search-dimension blur': 'searchTermChanged',
'.search-dimension search': 'searchTermChanged',
works
Alex
@whitecolor

is is possible to to like this

{{#each items "item"}}

//refere tho current item as "item", not {.} or this
{{item}}

{{/#item}}

?

Alexis Abril
@alexisabril

Any reason why binding to a list internally would be a bad idea?

var Person = can.Map.extend({
  define: {
    items: {
      set: function(val) {
        val.bind('change', console.log);
        return val;
      }
    }
  }
});

I believe we clean up those bindings when a new “items” list is set and when the instance of person is destroyed, but can’t recall offhand #lazyweb

Alexis Abril
@alexisabril

also, should the can.List change event be adding nested properties to the index argument?

var list = new can.List();

list.bind(‘change’, function(ev, index) {});

var foo = new can.Map({ name: ‘foo’ });
list.push(foo); //index is 0, expected

foo.attr(‘name’, ‘bar’); //index is 0.name, I would expect 0

http://jsbin.com/cuqato/1/edit?js,output

Chris Gomez
@akagomez
@alexisabril For your second example (“0.name”), that seems right to me. Since the “name” property changed on the item in the “0” index position.
Isn’t that argument called “attr”, not “index”? Context matters.
Alexis Abril
@alexisabril
@akagomez that’s true, we do document “index” as where the change took place. perhaps my issue is with calling it “index” in the docs: “0.name” isn’t the index
Chris Gomez
@akagomez
Yeah. Understandable. In a simple list, “attr” would look like “index”.
Alexis Abril
@alexisabril

What’s everyone’s approach to abstracting out arbitrary data from a model?

For instance, suppose a user model:

{ id: 0, name: ‘Alexis’ }

However, in the template we would also want:

{ isEditing: false }

You wouldn’t want to add that attribute directly to the model as it has no benefit being sent back to the server(just view noise).

The elegant answer is inheritable defines(I think), but I’m curious what everyone’s approach has been thus far.

opolyo01
@opolyo01
@alexisabril I just usually have some _.map somewhere in controller code that being passed to the template. It is probably better to abstract in the UI model class like you do.
Well, I am currently stuck with another issue that might not be can.js related, but part of can.js application that uses clientState
$.extend(true, {}, this.constructor.defaults, overrides)
jquery.js:300 Uncaught RangeError: Maximum call stack size exceeded
at Function.jQuery.extend.type (http://localhost:8126/bower_components/jquery/dist/jquery.js:300:16)
Has anyone ever had this issue? I simply extending two objects.. overrides has a property of clientState that is pretty big in size for some states
David Luecke
@daffl
@opolyo01 Could it be that you have a circular reference in your object tree? jQuery's deepExtend might not be able to deal with that.
Chris Gomez
@akagomez
@alexisabril Does serialize: false not handle that case? Or am I misunderstanding the problem?
opolyo01
@opolyo01
@daffl Yeah, it is. If I try to do JSON.stringify on it, it throws circular reference error. How do you deal with such issues? I am thinking to simply delete properties that cause circular reference, and update the code that relies on them.
avg6003
@avg6003
This message was deleted
This message was deleted
avg6003
@avg6003
can anyone tell me how to give fade effect on loading template? Here is my code:
'define(['can','jquery','jqueryui'], function(can,$) {
var PopUpController = can.Control.extend({
defaults: {
view: 'views/signup.hbs'
}
}, {
init: function(element, options) {
$('#popup').fadeIn('slow',function(element){
element.html(can.view(options.view, {}));
});
$('.content').click(function(){
$('#popup').fadeOut('slow');
})
},
})
return PopUpController;
})`
fadeOut is working but fadeIn isn't
I am new here sorry if there is some typo or formatiing!!
Nikolay Nadorichev
@Luanre
@DipeshRaichana you've inserted can.Control after fadeIn so jQuery can't animate unexisting DOM element
Alexis Abril
@alexisabril
@akagomez It definitely does and you would need to do that whether the property is on the map itself or on some inheriting map. However, if you have a large model with a lot of properties that are specific to a component’s view, those properties don’t need to be on the model itself. If that model is used in another component, with it’s own set of view related properties(isChecked, isHighlighted, isEditing, etc), the model itself gets polluted with arbitrary data.
Chris Gomez
@akagomez
@alexisabril I totally get you now. But I’m confused why those properties wouldn’t be on the ViewModel.
Instead of the Model.
Alexis Abril
@alexisabril

they would be on a viewmodel, just not the component’s necessarily. imagine you have a user model and your component has a user.list. user.isSelected could be some property you want to set.

In your view, you’d probably have something like:

{{#each users}}
<input type=“checkbox” can-value=“{isSelected}”/>
{{/each}}

isSelected would be convenient at some lower level than the component viewmodel itself, but not necessarily all the way down to the model.

Chris Gomez
@akagomez
I see. Just for fun, I think the way I’d handle that is to have a list of user models (users), and a list of selected users (selectedUsers). isSelected would be a helper that checks for the current user in the selectedUsers list.
Matthew Phillips
@matthewp
@alexisabril I think you want a component for each user in this case
Chris Gomez
@akagomez
Ah! +1 @matthewp
Matthew Phillips
@matthewp
or you could (this might be what you said) have a viewmodel that extends User
I remember us having this issue with sams
@Alfredo-Delgado i don't remember how we resolved that
probably with sub-components