Skip to content

Instantly share code, notes, and snippets.

@tomasznapieralski
Last active February 15, 2017 14:49
Show Gist options
  • Save tomasznapieralski/e90d92aab7f97b8513d0c2e667adae90 to your computer and use it in GitHub Desktop.
Save tomasznapieralski/e90d92aab7f97b8513d0c2e667adae90 to your computer and use it in GitHub Desktop.
jQuery bug
import Ember from 'ember';
export default Ember.Component.extend({
clicked: 0,
clickedVariant2: 0,
didInsertElement() {
this.$('#jquerybutton').on('click', () => {
this.$('.clickme').click();
});
this.$('#jquerybuttonVariant2').on('click', () => {
this.$('.clickmeVariant2').click();
});
},
actions: {
handleClick() {
this.set('clicked', this.get('clicked') + 1);
},
handleClickVariant2() {
this.set('clickedVariant2', this.get('clickedVariant2') + 1);
return false;
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to jQuery bug presentation</h1>
{{my-component}}
<h2>Variant 1, where action returns nothing</h2>
<div>click counter: {{clicked}}</div>
<h3>Click triggered by closure actions</h3>
<div onclick={{action "handleClick"}}>
<div class="clickme">click on text</div>
</div>
<h3>Click triggered by jQuery</h3>
<button id="jquerybutton">Button</button>
<h2>Variant 2, where action returns false explicitly</h2>
<div>click counter: {{clickedVariant2}}</div>
<h3>Click triggered by closure actions</h3>
<div onclick={{action "handleClickVariant2"}}>
<div class="clickmeVariant2">click on text</div>
</div>
<h3>Click triggered by jQuery</h3>
<button id="jquerybuttonVariant2">Button</button>
{
"version": "0.11.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.10.2",
"ember-data": "2.11.0",
"ember-template-compiler": "2.10.2",
"ember-testing": "2.10.2"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment