Skip to content

Commit 3609860

Browse files
committed
small corrections on jsRequire template
1 parent ede1f10 commit 3609860

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
1. Include your javascript in your .phtml file:
22

3+
<!-- Insert Js using script tag -->
34
<script type="text/x-magento-init">
45
{
5-
"*": {
6+
"<element_selector>": {
67
"${Identifier}": {
78
//"someOption": "someValue"
89
}
910
}
1011
}
11-
</script>
12+
</script>
13+
14+
<!-- Insert Js using data-mage-init element attribute -->
15+
data-mage-init='{
16+
"${Identifier}": {
17+
//"someOption": "someValue"
18+
}
19+
}'

templates/jsRequire/view/frontend/web/js/${identifier}.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/*jshint jquery:true*/
99
define([
1010
"jquery",
11-
"jquery/ui"
11+
"jquery/ui",
12+
'mage/translate'
1213
], function ($) {
1314
"use strict";
1415

@@ -22,7 +23,7 @@ define([
2223
* @private
2324
*/
2425
_create: function() {
25-
this.element.on('click', $.proxy(this._clickAction, this));
26+
this.element.on('click', $.proxy(this.clickAction, this));
2627
},
2728

2829
/**
@@ -33,12 +34,7 @@ define([
3334
// Do something if needed
3435
},
3536

36-
/**
37-
* Click action function
38-
* @private
39-
* @param event - {Object} - Click event.
40-
*/
41-
_clickAction: function(event) {
37+
clickAction: function(event) {
4238
// Do something with element clicked $(event.target)
4339
}
4440
});

0 commit comments

Comments
 (0)