Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 17:25
    matthewp edited #5384
  • 17:00

    matthewp on can-dom-mutate-2.0.7

    (compare)

  • 17:00

    matthewp on master

    fix(package): update can-dom-mu… Merge pull request #5386 from c… (compare)

  • 17:00
    matthewp closed #5386
  • 16:27
    greenkeeper[bot] labeled #5386
  • 16:27
    greenkeeper[bot] opened #5386
  • 16:27

    greenkeeper[bot] on can-dom-mutate-2.0.7

    fix(package): update can-dom-mu… (compare)

  • 16:25

    matthewp on can-dom-mutate-2.0.6

    (compare)

  • 16:24
    matthewp closed #5379
  • 16:24
    matthewp commented #5379
  • 15:26

    greenkeeper[bot] on can-type-1.1.2

    (compare)

  • 15:26

    matthewp on master

    fix(package): update can-type t… Merge pull request #5385 from c… (compare)

  • 15:26
    matthewp closed #5385
  • 14:11
    matthewp closed #5377
  • 14:11
    matthewp closed #5376
  • 14:11
    matthewp closed #5375
  • 14:07
    greenkeeper[bot] labeled #5385
  • 14:07
    greenkeeper[bot] opened #5385
  • 14:07

    greenkeeper[bot] on can-type-1.1.2

    fix(package): update can-type t… (compare)

  • Oct 16 20:07
    matthewp commented #5384
Kevin Phillips
@phillipskevin
@AntonProkofyev you can access the viewModel with this.viewModel
but the better way would be to use can-stache-bindings to do something like <li class="listItem" ($click)="clickHandler(this)">
and have a clickHandler: function(item) { ... } on your viewModel
we are live :-)
Justin Meyer
@justinbmeyer
just finished going through all the cool stream stuff
Gregg Roemhildt
@roemhildtg
Inline partials are awesome. Are they available in the scope for other partials to use? So if I have
{{<partialName}}
  <li>
    {{.name}}
    <ul>
      {{#each .children}}
        {{>partialName .}}
      {{/each}}
    </ul>
  </li>
{{/partialName}}

<ul>
  {{>otherPartial}} <!-- can otherPartial access partial "partialName"? -->
  <li>( {{message}} )</li>
</ul>
James Atherton
@James0x57
I didn't specifically test that, but that should work no problem - just declare both named partials in the template and they should be able to reference each other
Glad you like it :D
Gregg Roemhildt
@roemhildtg
I do. I also just learned you can pass a scope to a partial
James Atherton
@James0x57
Just tested, they can reference each other:
    test('named partials can reference each other (canjs/can-stache/issues/3)', function(){
        var template = "{{<foo}}hello {{>bar}}{{/foo}} {{<bar}}world{{/bar}} <span>Test:</span><div>{{>foo}}</div>";
        var intermediate = parser( template, {}, true );

        var renderer = stache(intermediate);
        var data = new CanMap( {} );
        var frag = renderer( data );

        equal( innerHTML( frag.lastChild ), "hello world" );;
    });
Gregg Roemhildt
@roemhildtg
So I could do something like
{{<name}}
{{#if userName}}
<b>{{userName}}</b> <!-- if username exists render bold username -->
{{else}}
{{>bar}} <!-- otherwise render a default partial defined in the template-->
{{/if}}
{{>name}}
for example
James Atherton
@James0x57
Sure. I imagine it'll be used for more complex composition but that'd work as a test. Gotta close the {{<name}} tag with {{/name}} though
Gregg Roemhildt
@roemhildtg
Yup, good catch. I use partials a lot, (maybe too much) to override different parts of a page component based on a data type. So now I could create the partial in the template and if a partial gets passed to the component, that partial can render the partial defined in the template if it wants to
James Atherton
@James0x57
yup
:)
Nico R.
@nriesco
@James0x57 what do I need to do yo use named partials? (canjs/can-stache#3) update my canjs version?
Nico R.
@nriesco
And is there a working example (jsbin?)
Kevin Phillips
@phillipskevin
@nriesco it will be in canjs soon if you're using the main can package
otherwise, just update to can-stache 3.6.0
Nico R.
@nriesco
cool, thanks @phillipskevin
kostya.aderiho
@kaderiho

Hi all, I have the next DefineMap instance:

const Attachment = DefineMap.extend({
    attachmentTO: {
        attachmentType: 'string',
        resourceType: 'string',
        contentType: 'string',
        entityType: 'string',
        entityId: 'string',
        fileSize: 'number',
        urlName: 'string',
        clientId: 'number',
        status: 'string',
        id: 'string'
    },
    downloadUrl: null,
    uploadUrl: null
});

and I need to set id in Algebra something like this:

const attachmentsAlgebra = new set.Algebra(
    set.props.id('attachmentTo.id')
);

but it doesn't work, could someone help how I have to set id in Algebra?

Nico R.
@nriesco
@kaderiho I don't know much about algebra but first check the case of attachmentTO (the last letter)
kostya.aderiho
@kaderiho
:)
I should be TO of course, fixed for not confusing
Kevin Phillips
@phillipskevin
if that did not solve your problem, please open an issue
kostya.aderiho
@kaderiho
but with TO doesn't work so far :(
Kevin Phillips
@phillipskevin
I'm not sure if using nested properties is supported
so we may need to add this as an enhancement
kostya.aderiho
@kaderiho
could you please say where I can write about this issue?
Kevin Phillips
@phillipskevin
kostya.aderiho
@kaderiho
I mean for guys who work on canjs
okey, many thanks
Nico R.
@nriesco

I have a component that looks like this:

export default Component.extend({
  tag: 'my-tag',
  ViewModel,
  view,
  events: {
    inserted: function() {
      console.log('this works!');
    }
  }
});

and will show 'this works!' in the console. I tried to guess other events such as 'resize', 'onresize', etc.. but none of them workded. How can I know for sure what are the possible events that will be triggered? somehow I know 'inserted' is available, but what about the rest?

Thanks

BTW: I’m trying to detect an element resize event (a div for example). A Window resize won’t work because I need the real width of the element that depends on several show/hidden blocks
Gregg Roemhildt
@roemhildtg
Are you sure elements actually dispatch resize events? I thought that was only on the window object.
Nico R.
@nriesco
I don’t know who triggers the “inserted” event, nor what other events could be triggered.
I can trigger a click event, that works
maybe the approach is totally wrong, but still there must be a list of events that can be used there
Gregg Roemhildt
@roemhildtg
Yep, I was just going to link that page. I think for the most part, that events block is just for inserted removed and viewmodel listeners. Like {viewModel} propertyName to listen for when propertyName changes
Nico R.
@nriesco
I think I might have an idea..
ok this works
export default Component.extend({
  tag: 'my-tag',
  ViewModel,
  view,
  events: {
    inserted: function(el) {
      $(window).on('resize', function() {
        console.log('this works too!!!');
      });
    }
  }
});
thanks @roemhildtg
Nico R.
@nriesco
one question thought...
the $(window)… part.. is that jQuery? this is a donejs project and I never imported jQuery… but it works, weird isn’t it?