File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 1
1
1. Include your javascript in your .phtml file:
2
2
3
+ <!-- Insert Js using script tag -->
3
4
<script type="text/x-magento-init">
4
5
{
5
- "* ": {
6
+ "<element_selector> ": {
6
7
"${Identifier}": {
7
8
//"someOption": "someValue"
8
9
}
9
10
}
10
11
}
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
+ }'
Original file line number Diff line number Diff line change 8
8
/*jshint jquery:true*/
9
9
define ( [
10
10
"jquery" ,
11
- "jquery/ui"
11
+ "jquery/ui" ,
12
+ 'mage/translate'
12
13
] , function ( $ ) {
13
14
"use strict" ;
14
15
@@ -22,7 +23,7 @@ define([
22
23
* @private
23
24
*/
24
25
_create : function ( ) {
25
- this . element . on ( 'click' , $ . proxy ( this . _clickAction , this ) ) ;
26
+ this . element . on ( 'click' , $ . proxy ( this . clickAction , this ) ) ;
26
27
} ,
27
28
28
29
/**
@@ -33,12 +34,7 @@ define([
33
34
// Do something if needed
34
35
} ,
35
36
36
- /**
37
- * Click action function
38
- * @private
39
- * @param event - {Object} - Click event.
40
- */
41
- _clickAction : function ( event ) {
37
+ clickAction : function ( event ) {
42
38
// Do something with element clicked $(event.target)
43
39
}
44
40
} ) ;
You can’t perform that action at this time.
0 commit comments