Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Dimitris
    @ambicoder
    I have tried undelegate events..unbind..etc
    you are right about what you say though...
    Dimitris
    @ambicoder
    I have understood what the problem in theory is...but I do not know how to tackle the coding
    Dimitris
    @ambicoder
    Julian Gonggrijp
    @jgonggrijp
    @ambicoder Sorry I don't have time to look into it in more detail at this time. In any case though, don't just try things out. You need to really understand what's going on before you can fix anything. I suggest stepping through your code with a debugger, setting breakpoints and inspecting live variables until you fully understand why your bug is happening.
    Dimitris
    @ambicoder
    ok...in the process I will have to makse some questions...such as...when calling object render does that create a new instance such as new object()?
    Julian Gonggrijp
    @jgonggrijp
    @ambicoder aView.render() normally does not create a new object, but your tooltipview is calling tippy inside its render method. I suspect tippy is creating a new object (specifically, DOM elements) behind your back every time you call it.
    Dimitris
    @ambicoder
    is there a problem calling an object (on the render metho)inside a view?
    Julian Gonggrijp
    @jgonggrijp
    No that's fine in general. You do want to manage the resources that are created inside your view, though, so you can clean them up when you no longer need them.
    Dimitris
    @ambicoder
    ....can you say a little more on "clean when no longer needed"?
    Julian Gonggrijp
    @jgonggrijp
    Schermafbeelding 2021-03-16 om 20.13.10.png
    @ambicoder When you call tippy, it creates this tooltip widget. That's a div somewhere in the document with some classes and styling to position it relative to the event and to give it this particular look.
    This div should be removed again when you no longer need it. That's what I mean by "cleaning up".
    In an earlier version, you had the tooltips of two different events layered on top of each other. I think that happened because the tooltips were never removed.
    dimtabu
    @taburetkin
    @jgonggrijp hi!
    can you explain what exactly this line does ?
    attrs = _.defaults(_.extend({}, defaults, attrs), defaults);
    what the difference between just _.extend({}, defaults, attrs);
    i can see only one reason to doing that
    if attrs contains property with undefined value it will override the default one.
    and _.defaults() just replace undefined properties back to the defaults.
    correct me if there is something else
    Julian Gonggrijp
    @jgonggrijp
    @taburetkin Interesting question! Just to be clear, I'm not the original author... but let's take a look at createAssigner.
    dimtabu
    @taburetkin
    i am asking you because you are very familiar with underscore and this is actually underscore magic if you understand me )
    Julian Gonggrijp
    @jgonggrijp
    Yeah I understand. To be honest, I don't see how this expression could result in a different value than just _.defaults({}, attrs, defaults).
    But before we jump to conclusions, I suggest doing a git blame. There is probably some non-obvious reason why this is needed.
    Or maybe it was just somebody who didn't know what they were doing.
    dimtabu
    @taburetkin
    let attr = { foo: 'bar', baz: undefined };
    let defaults = { baz: 'boo' };
    let extendResult = _.extend({}, defaults, attr);
    // { foo: 'bar', baz: undefined }
    let defaultsResult = _.defaults(extendResult, defaults);
    // { foo: 'bar', baz: 'boo' }
    i thought that this was made for this case
    i mean i am thinking that for this. but i can be wrong or can miss something else
    Julian Gonggrijp
    @jgonggrijp
    @taburetkin So what is _.defaults({}, attr, defaults)?
    dimtabu
    @taburetkin
    defaults ignores properties if they have material values
    extend does not
    if i understood it correct
    Julian Gonggrijp
    @jgonggrijp
    @taburetkin Yes but notice the order.
    dimtabu
    @taburetkin
    _.extend({foo: 'bar' }, { foo: undefined}) => { foo: undefined}
    _defaults({foo: 'bar' }, { foo: undefined}) => {foo: 'bar' }
    so, i suppose that if you have default material value, say foo: 'bar' and you somehow provide initial attrs with own property foo without value ({foo: undefined}) the default value will not take effect after extend.
    and as i think thats why there is extend in first place and defaults in second, just to return default values for properties which was occasionly passed without values but has default values defined.
    i thought maybe there is something else )
    dimtabu
    @taburetkin
    also i suppose that this operation can be more faster if you have own extend method which can be setuped through options.
    something like extend(oneObject, secondObject, { ignoreUndefined: true, ignoreFunctions: true, ... })
    personaly in most cases i treat undefined as missed(not material) values and { property: undefined } is literally equal to {} at least for me
    Julian Gonggrijp
    @jgonggrijp

    @taburetkin I found jashkenas/backbone@92fb299 and this. The change was motivated by an exotic edge case. I'm not convinced that it was a good change, since that first PR also removes a perfectly valid test for a much more common scenario. It is basically increasing code complexity in order to support overriding non-enumerable Object.prototype properties.

    For undefined you don't need, it _.defaults by itself will already do the same job:

    a = {foo: 'bar'}
    // {foo: "bar"}
    b = {foo: undefined}
    // {foo: undefined}
    _.extend({}, a, b)
    // {foo: undefined}
    _.extend({}, b, a)
    // {foo: "bar"}
    _.defaults({}, a, b)
    // {foo: "bar"}
    _.defaults({}, b, a)
    // {foo: "bar"}
    _.defaults(_.extend({}, a, b), a)
    // {foo: "bar"}
    _.defaults(_.extend({}, b, a), b)
    // {foo: "bar"}
    dimtabu
    @taburetkin
    @jgonggrijp yeah, thanks. my eng is not good enough. as i can see from discussion my suppose was correct
    thank you for your attention )
    now i am struggling with underscore isEqual. i have take a look at this function and it seems to me awful.
    Julian Gonggrijp
    @jgonggrijp
    @taburetkin Agree, definitely not the prettiest of the bunch. Seems like people have wanted it to do everything.
    Dimitris
    @ambicoder
    @jgonggrijp you were right from thr beiginning...two event listeners were added per each event....I thougt the problem was related to the backbone code...but no..it was error in the tooltip initialization...my fault....thanks fro the help
    Julian Gonggrijp
    @jgonggrijp
    @ambicoder Welcome.
    Dimitris
    @ambicoder
    a collection how many models can it contain...is there a limit...set by memory maybe?
    Julian Gonggrijp
    @jgonggrijp
    @ambicoder It uses a regular array internally. There is a limit on the size of an array in JS but it is 2^53 if I'm right, so you're unlikely to hit it. What is the problem you're facing?