Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(require): bind multiple events with single common handler #11

Merged
merged 3 commits into from
Jun 20, 2016

Conversation

frostbane
Copy link
Contributor

@frostbane frostbane commented Jun 15, 2016

I was browsing through the Ractive documentation and saw

<div on-mouseover-mousemove='set( "hover", true )'>...</div>

and I thought that

data-on-childevent1-childevent2-....="parentevent"
<!-- when any of the childeventN is fired parentevent will get fired -->
data-listen-childevent1-childevent2-...="parentevent"
<!-- when parentevent is fired all of the childeventNs will also get fired -->

could also be possible.

Here's a sample on how I use it:

<rv-require name="dataList"
            src="widgets/data-list"
            data-title="等級色分類"
            data-addbtnlabel="追加・変更"
            data-sortable="false"
            data-on-resetdata-cleardata="clear-list-data"
            data-listen-clearselected-resetrange="clear-ranges"></rv-require>

@XavierBoubert
Copy link
Member

Thanks again @frostbane!

Please can you follow the coding style?

name.split('-').forEach(function(eventName) {
  if (eventName.trim()) {
    events[eventName] = attr.value;
  }
});

@XavierBoubert
Copy link
Member

XavierBoubert commented Jun 16, 2016

I have updated the documentation with your work 😉

http://ractive-require.codecorico.com/#events

@frostbane
Copy link
Contributor Author

I have refactored the code.

@XavierBoubert
Copy link
Member

Sorry sorry but a if, even in single ligne needs its brackets. 😅

if (eventName.trim()) {
  events[eventName] = attr.value;
}

@XavierBoubert
Copy link
Member

(I prefer to let you correct that to add commits after your work 😉)

@XavierBoubert
Copy link
Member

(And strings are always in ' instead of ")

More on the JSCS rules

@XavierBoubert
Copy link
Member

Perfect!

@XavierBoubert XavierBoubert merged commit 06f68dd into CodeCorico:master Jun 20, 2016
@frostbane frostbane deleted the feature/multiple-events branch June 20, 2016 08:11
@XavierBoubert
Copy link
Member

Released in 0.6.4

@XavierBoubert
Copy link
Member

0.6.5 in fact.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants