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)

that's show the bug the console.log's should be in the opposite order
cc @daffl
Dovid Bleier
@dbleier
is there a component event similar to "inserted" that is fired when an update is made to the stache template?
Mohamed Cherif Bouchelaghem
@cherifGsoul
@dbleier you mean DOM event?
Dovid Bleier
@dbleier
@cherifGsoul I guess it would be a DOM event. It doesn't really matter. I just need a hook to know when the template has been updated so I can rebind my jquery plugin to the updated content.
Alex
@whitecolor
@dbleier what do you mean updated? why would need to rebind the plugin?
Mohamed Cherif Bouchelaghem
@cherifGsoul
@dbleier you can put your custom events in the events object for the component:
can.Component.extend({
tag:'x-el',
template:aTpl,
events:{
'li click':function(){
// handle it
}
}
});
Mohamed Cherif Bouchelaghem
@cherifGsoul
@dbleier can you give an example for your use case?
Jeroen Cornelissen
@jeroencornelissen
How do can.Components cope with screenreaders? Do you guys take accessibility into account?
We are creating a new menu for our webapp and I want to make it accessible for all users.
Dovid Bleier
@dbleier
@cherifGsoul, @whitecolor the custom events are usually user triggered events. I need to know when the template has finished updating itself. The use case is this: I have a div containing a series of divs. I bind a jquery plugin called cylce2 to the parent div which cycles through the children divs (containing img or video) in a slideshow. When the viewModel id is changed (via scheduling) it updates the template with all new content, including new content for that div, which then crashes cycle2. So when the viewModel id is updated, I want to remove the plugin (can-define) and once the content is done updating, reattach the plugin. I just don't know how to know when the template is finished updating. Basically I need an event like "inserted" called "updated". Make sense?
Mohamed Cherif Bouchelaghem
@cherifGsoul
@dbleier why you need to disable define plugin?
Alex
@whitecolor
@dbleier I'd better to create custom element something my-cycle2 which will handle erythinkng (jquery plugin lifecycle) within itself, when the id of doc is changed it can either handl this update inside or be replaced with new instance
{{#doc}}<my-cycle {doc}=doc/>{{/doc}}
Mohamed Cherif Bouchelaghem
@cherifGsoul
Im writing a jsbin example for better understanding
Mohamed Cherif Bouchelaghem
@cherifGsoul
@dbleier here is a basic example with cycle2 http://jsbin.com/qejilo/4/edit?html,css,js,output you can clone it and explain your problem
Adam Tourkow
@atourkow
I have component I want to update via ajax based on a timer. Should, I just build a function into the component called updateStuff: function() { doAjaxStuff ... } and just call updateStuff()?
Mason Shin
@minsooshin
I have a small question about model
what is recommended between callback and promise for success and error?
for instance, if I have a model with Todo
Todo.findAll({}, success, error) or Todo.findAll({}).then()?
Kevin Phillips
@phillipskevin
@atourkow when you say a timer, you mean it’s going to do a setTimeout and update every few seconds or something?
Adam Tourkow
@atourkow
@phillipskevin Yeah. But, I also would like to apply ajax to something like a search. FWIW, it's not a SPA app, but just a section of the page.
Kevin Phillips
@phillipskevin
so, something like… every 5 seconds make an ajax call and update your viewModel based on the response?
Adam Tourkow
@atourkow
@phillipskevin yep. The search and timer are separate things.
I think what's confusing me, is the fact that there's "can.model" which is for like REST api calls. Should I be putting the ajax calls in the model or in the ViewModel?
Kevin Phillips
@phillipskevin
usually, the ViewModel would call the model
and the model would be responsible for the ajax stuff
Adam Tourkow
@atourkow
So, like in the viewmodel is a function called updateStuff that calls the model?
Kevin Phillips
@phillipskevin
the most basic way is to use the model to initialize your viewmodel
so you have a property on your viewModel that represents whatever data is returned by the Model
in that example, the players property ends up being a promise
Another nice way to do it is to have two separate properties - one for the promise and one for the data
so that uses the asynchronous getter to set game to be the data returned by Game.get
that’s nice because you can use the promise in your template, but also use the data
Adam Tourkow
@atourkow
I get the init, but does that also include updating?
Kevin Phillips
@phillipskevin
like:
{{#if gamePromise.isResolved}}
    {{#game.homeTeam.score}} - {{#game.awayTeam.score}}
{{/if}}
yes, if you use the get: function(last, set){ approach, it would update whenever gamePromise changes
that getter sets up binding so that if it changes, the template will update
if you use value it’s just setting the intitial value, so it won’t handle updates
Adam Tourkow
@atourkow
So, you can just call viewModel.get() to refresh from ajax?
Kevin Phillips
@phillipskevin
if your template uses game that will happen automatically
viewModel.attr(‘game’) calls that get()
but what you’ll need to do in your case is set up some way that gamePromise will return a new promise after some amount of time
I would try something like this:
define: {
  gamePromise: {
    get: function() {
      return this.getGamePromise();

      setTimeout(this.getGamePromise, 5000);
    }
  }
},
getGamePromise: function() {
  return Game.get({...})
}
hmm, that’s not going to work… because it won’t change the return value of gamePromise
let me try it in a JSBin
Adam Tourkow
@atourkow
It seems like there's a lot of ways to do things in canJS.