Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 16 20:07
    matthewp commented #5384
  • Oct 16 20:06
    matthewp labeled #5384
  • Oct 16 20:06
    matthewp opened #5384
  • Oct 16 19:53
    matthewp opened #5383
  • Oct 16 16:23
    phillipskevin closed #4841
  • Oct 15 21:43

    phillipskevin on master

    Update dist for release (compare)

  • Oct 15 21:43

    phillipskevin on v6.1.1

    Update dist for release 6.1.1 (compare)

  • Oct 15 21:34

    phillipskevin on can-observable-mixin-1.0.2

    (compare)

  • Oct 15 21:34

    phillipskevin on master

    fix(package): update can-observ… Merge branch 'master' into gree… Merge pull request #5382 from c… (compare)

  • Oct 15 21:34
    phillipskevin closed #5382
  • Oct 15 21:34

    phillipskevin on can-make-map-1.2.2

    (compare)

  • Oct 15 21:34

    phillipskevin on master

    fix(package): update can-make-m… Merge pull request #5380 from c… (compare)

  • Oct 15 21:34
    phillipskevin closed #5380
  • Oct 15 20:30
    phillipskevin synchronize #5382
  • Oct 15 20:30

    phillipskevin on can-observable-mixin-1.0.2

    fix(package): update can-observ… fix(package): update can-simple… Merge pull request #5372 from c… and 2 more (compare)

  • Oct 15 20:30
    phillipskevin opened #5382
  • Oct 15 20:28

    phillipskevin on can-simple-map-4.3.3

    (compare)

  • Oct 15 20:28

    phillipskevin on master

    fix(package): update can-simple… Merge pull request #5378 from c… (compare)

  • Oct 15 20:28
    phillipskevin closed #5378
  • Oct 15 20:26

    phillipskevin on can-observable-mixin-1.0.1

    (compare)

Justin Meyer
@justinbmeyer
he implied a loop
you can do a for in loop of the instance.constructor.prototype
then check to make sure the property is .hasOwnProperty() on that object
Chris
@chrischrischris
Hi, Is there a way to determine if a control is currently bound to an element?
Justin Meyer
@justinbmeyer
I think a control adds to the element's data
if you're using jquery, $(element).data("control")
I think
controls
Chris
@chrischrischris
Perfect, thanks Justin!
Adam L Barrett
@BigAB
@matthewp @justinbmeyer Yeah, so that doesn’t quite get what I wanted, as there is still setup in there, and constructor, and I end up having to walk up and check the prototype chain to look for any more methods (from already extended constructors). So I take it we don’t hold onto those propertyDefinition objects anywhere then eh? That’s alright, I’ll look into a different approach.
Kevin Phillips
@phillipskevin
@BigAB when are you looking to do this? in your actual app? in a test?
Adam L Barrett
@BigAB
@phillipskevin Looking for a way in my can-react implementation, to copy (and bind) the methods defined on a DefineMap into the object to be passed as props to the connected component
https://github.com/BigAB/can-react/blob/master/src/can-react.js#L66
Currently I am copying (and binding) and property that is a function, but I figured that was excessive, as presumably, they would only be expecting to pass any methods the DefineMap had.. ..uh… defined.
To answer the “about to be asked” question, “Why not pass the whole DefineMap instance”, react throws a little warning if you try to pass anythign other than a plain object as props
Kevin Phillips
@phillipskevin
ok, thanks for explaining
I don’t have a better idea
if you figure out a different approach I’d be interested to hear it though
Adam L Barrett
@BigAB
I am considering putting the pressure on the other side, and only copying over methods defined in the React Components propTypes
This would force users to define their propTypes in the component, which though encouraged, is not enforced
Matthew Phillips
@matthewp
I think walking up the prototype chain is what you want to do
walk up the chain until you get to DefineMap and stop there
if your goal is to get a list of non-definemap functions that is
Adam L Barrett
@BigAB
@matthewp So you think i should just sort of blacklist setup which seems to always be there (as well as constructor)
Matthew Phillips
@matthewp
Yeah, sounds fine to me
if you know this is a DefineMap/Map, it's ok that you have hardcoded that
constructor applies to all objects
so no prob there either
this is metaprogramming so doesn't need to be easy/clean :)
Justin Meyer
@justinbmeyer
@BigAB what I'm saying should work
setup shouldn't be there. Maybe constructor ... that is the only one.
Christopher Oliphant
@RALifeCoach
Is it possible to create a viewModel as a class?
export default class XxxViewModel extends DefineMap {
    ??

    onButtonClick() {
        …
    }
}
Matthew Phillips
@matthewp
Probably not yet
Maybe if you call the static .setup() method
Christopher Oliphant
@RALifeCoach
It seems to work if I define the properties and methods in the constructor.
Christopher Oliphant
@RALifeCoach
The methods need to be static or defined in the component events
Christopher Oliphant
@RALifeCoach
Nope - you’re right - it doesn’t work
Christopher Oliphant
@RALifeCoach
I am now trying the following:
const X = DefineMap.extend({
    y: {
        type: ‘string’,
        value: ‘yyyy’
    },
    onClickY: function () {
        console.log(‘click y’);
    }
});

const A = X.extend({
    b: {
        type: ‘string’,
        value: ‘bbbbbb’
    },
    onClickB: function () {
        console.log(‘click b’);
    }
});

Component.extend({
    tag: ‘x-a’,
    template: …
    ViewModel: A
});
Both ClickY and ClickB work, but the field y is given a warning - undefined - in the stache template
Christopher Oliphant
@RALifeCoach
is there a JSBin already setup for canjs 3.0?
Christopher Oliphant
@RALifeCoach
When I upgrade to the latest can-define - the above gives an error “Cannot redefine property: _data"
Justin Meyer
@justinbmeyer
upgrade again
I just pushed a fix for that
Christopher Oliphant
@RALifeCoach
thanks
Justin Meyer
@justinbmeyer
portfolio-systems
@portfolio-systems

Is it possible to 2-way bind a checkbox to a named attribute such that it just works (no additional JS) and if so how ??

Compare and contrast :

CHECKBOX
{{#each choices}}
<nput type=“checkbox” name=“cb1” value=“{{.}}” some-magic-binding/>
{{/each}}

SELECT
<select name=“select1” multiple {($value)}=“answer”>
{{#each choices}}
<option value=“{{.}}”>{{.}}</option>
{{/each}}
</select>

with this data
{
choices: [1,2,3,4,5],
answer: ‘2;4'
}

Select works out of the box but checkbox does not despite trying every variant of some-magic-binding known to man.

The best I can do is to use {($checked)}=“checked” as the some-magic-binding. This works but I have to run a js routine to init the checked attributes at page load time.

Seems like a major hack but I can’t find any other way.

Surely the whole point of live binding is to avoid this sort of explicit intervention. It would be REALLY good if checkboxes behaved like multiple selects.

What am I missing ??

Kevin Phillips
@phillipskevin
in 2.3, you do need some additional js
you can take a look at the checkbox.stache and checkbox.js files here: https://gist.github.com/phillipskevin/a5892f9f1cf9a4d4ce936beb9080e615