Get changing variables from Magento block in knockout jsMagento2 override admin js fileCheckout uiComponent (input field) rendered multiple times: how do I apply viewmodel functionality to current input field only?Magento 2: Initialize calendar widget inside payment uiComponentMagento2 : How to get home url in Knockout HTML templateMagento 2 Knockout JS (access UiClass from foreach)How to get function caller file path in knockout js?Magento2: customerData works different on Product Page?How to translate knockout string variables in Magento 2Magento2: Get product date in Knockout JsHow to hide particular admin form field(UI Component) based on the value of select field?
How did Captain America manage to do this?
Why is the underscore command _ useful?
All ASCII characters with a given bit count
Contradiction proof for inequality of P and NP?
Why do distances seem to matter in the Foundation world?
Is Diceware more secure than a long passphrase?
How can I get rid of an unhelpful parallel branch when unpivoting a single row?
Which big number is bigger?
How to fry ground beef so it is well-browned
A strange hotel
How to not starve gigantic beasts
How to remove these lines in Altium Design
Negative Resistance
I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?
Philosophical question on logistic regression: why isn't the optimal threshold value trained?
Which term is being referred to with "reflected-sound-of-underground-spirits"?
How bug prioritization works in agile projects vs non agile
Why did C use the -> operator instead of reusing the . operator?
How to read .npy file in Mathematica?
Can someone publish a story that happened to you?
Can I criticise the more senior developers around me for not writing clean code?
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
Zonal Statistics is returning null values in ArcGIS Desktop?
Covering null sets by a finite number of intervals
Get changing variables from Magento block in knockout js
Magento2 override admin js fileCheckout uiComponent (input field) rendered multiple times: how do I apply viewmodel functionality to current input field only?Magento 2: Initialize calendar widget inside payment uiComponentMagento2 : How to get home url in Knockout HTML templateMagento 2 Knockout JS (access UiClass from foreach)How to get function caller file path in knockout js?Magento2: customerData works different on Product Page?How to translate knockout string variables in Magento 2Magento2: Get product date in Knockout JsHow to hide particular admin form field(UI Component) based on the value of select field?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Want to pass entityId to the getInfo method:
This block.phtml is on the catalog page (list) that gets called per Item on the page and sends each entity id to the getInfo method. The getInfo method then calls a controller that returns the info. If I add entityId to the initialize method only the first / last value gets passed to the getInfo method...
block.phtml
<script type="text/x-magento-init">
"#custom-component":
"Magento_Ui/js/core/app":
"components":
"customcomponent":
"component": "ACME_KnockoutDemo/js/custom-component",
"template" : "ACME_KnockoutDemo/custom-component",
"entityId": "<?= /* @escapeNotVerified */ $product->getId() ?>"
</script>
custom-component.js
define([
'uiComponent',
'ko',
'mage/url',
'mage/storage',
], function (Component, ko, urlBuilder,storage)
'use strict';
return Component.extend(
initialize: function ()
this._super();
,
getInfo:function ()
var serviceUrl = urlBuilder.build('acme/getinfo?id=' + #ENTITIYID);
storage.post(
serviceUrl,
''
).done(
function (response)
var jsonObj = JSON.parse(response);
this.info = jsonObj.info;
).fail(
function (response)
);
);
);
custom-component.html
<div data-bind="scope: getInfo()">
<p data-bind="text: info"></p>
</div>
magento2 knockoutjs
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Want to pass entityId to the getInfo method:
This block.phtml is on the catalog page (list) that gets called per Item on the page and sends each entity id to the getInfo method. The getInfo method then calls a controller that returns the info. If I add entityId to the initialize method only the first / last value gets passed to the getInfo method...
block.phtml
<script type="text/x-magento-init">
"#custom-component":
"Magento_Ui/js/core/app":
"components":
"customcomponent":
"component": "ACME_KnockoutDemo/js/custom-component",
"template" : "ACME_KnockoutDemo/custom-component",
"entityId": "<?= /* @escapeNotVerified */ $product->getId() ?>"
</script>
custom-component.js
define([
'uiComponent',
'ko',
'mage/url',
'mage/storage',
], function (Component, ko, urlBuilder,storage)
'use strict';
return Component.extend(
initialize: function ()
this._super();
,
getInfo:function ()
var serviceUrl = urlBuilder.build('acme/getinfo?id=' + #ENTITIYID);
storage.post(
serviceUrl,
''
).done(
function (response)
var jsonObj = JSON.parse(response);
this.info = jsonObj.info;
).fail(
function (response)
);
);
);
custom-component.html
<div data-bind="scope: getInfo()">
<p data-bind="text: info"></p>
</div>
magento2 knockoutjs
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Want to pass entityId to the getInfo method:
This block.phtml is on the catalog page (list) that gets called per Item on the page and sends each entity id to the getInfo method. The getInfo method then calls a controller that returns the info. If I add entityId to the initialize method only the first / last value gets passed to the getInfo method...
block.phtml
<script type="text/x-magento-init">
"#custom-component":
"Magento_Ui/js/core/app":
"components":
"customcomponent":
"component": "ACME_KnockoutDemo/js/custom-component",
"template" : "ACME_KnockoutDemo/custom-component",
"entityId": "<?= /* @escapeNotVerified */ $product->getId() ?>"
</script>
custom-component.js
define([
'uiComponent',
'ko',
'mage/url',
'mage/storage',
], function (Component, ko, urlBuilder,storage)
'use strict';
return Component.extend(
initialize: function ()
this._super();
,
getInfo:function ()
var serviceUrl = urlBuilder.build('acme/getinfo?id=' + #ENTITIYID);
storage.post(
serviceUrl,
''
).done(
function (response)
var jsonObj = JSON.parse(response);
this.info = jsonObj.info;
).fail(
function (response)
);
);
);
custom-component.html
<div data-bind="scope: getInfo()">
<p data-bind="text: info"></p>
</div>
magento2 knockoutjs
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Want to pass entityId to the getInfo method:
This block.phtml is on the catalog page (list) that gets called per Item on the page and sends each entity id to the getInfo method. The getInfo method then calls a controller that returns the info. If I add entityId to the initialize method only the first / last value gets passed to the getInfo method...
block.phtml
<script type="text/x-magento-init">
"#custom-component":
"Magento_Ui/js/core/app":
"components":
"customcomponent":
"component": "ACME_KnockoutDemo/js/custom-component",
"template" : "ACME_KnockoutDemo/custom-component",
"entityId": "<?= /* @escapeNotVerified */ $product->getId() ?>"
</script>
custom-component.js
define([
'uiComponent',
'ko',
'mage/url',
'mage/storage',
], function (Component, ko, urlBuilder,storage)
'use strict';
return Component.extend(
initialize: function ()
this._super();
,
getInfo:function ()
var serviceUrl = urlBuilder.build('acme/getinfo?id=' + #ENTITIYID);
storage.post(
serviceUrl,
''
).done(
function (response)
var jsonObj = JSON.parse(response);
this.info = jsonObj.info;
).fail(
function (response)
);
);
);
custom-component.html
<div data-bind="scope: getInfo()">
<p data-bind="text: info"></p>
</div>
magento2 knockoutjs
magento2 knockoutjs
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 hour ago
StephanStephan
62
62
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Stephan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272569%2fget-changing-variables-from-magento-block-in-knockout-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Stephan is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272569%2fget-changing-variables-from-magento-block-in-knockout-js%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown