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;








1















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>









share|improve this question







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.


























    1















    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>









    share|improve this question







    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.






















      1












      1








      1








      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>









      share|improve this question







      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






      share|improve this question







      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.











      share|improve this question







      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.









      share|improve this question




      share|improve this question






      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.




















          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.









          draft saved

          draft discarded


















          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.









          draft saved

          draft discarded


















          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          منجزی محتویات تیره‌های طایفه منجزی[ویرایش] مشاهیر طایفه منجزی[ویرایش] محل سکونت[ویرایش] پانویس[ویرایش] منابع[ویرایش] منوی ناوبری«نمودار اجتماعی طوایف بختیاری»«BakhtyārBAḴTĪĀRĪ TRIBE»«اسامی طوایف و شعب ایل بختیاری»ووگسترش آن

          What does the writing on Poe's helmet say? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Favorite questions and answers from first quarter of 2019 Latest Blog Post: Avengers: Endgame PredictionsWhat is the purpose of the blast shield helmet?Why was the Stormtrooper helmet designed this way?What does Kylo Ren place his helmet on?What does the writing on Poe Dameron's flight vest say?Is this Poe Damerons dad? (Kes Dameron)Is Poe Dameron Force-Sensitive?Why is Poe Dameron so shocked in the First Order star destroyer hangar?What does the code breaker's hat say?In “The Last Jedi” was it actually Poe's fault that so much of the resistance died?Did Poe Dameron make custom modifications to his black X-Wing?

          How to implement Time Range Picker in Magento 2 Admin system.xml? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Date field system.xmlMagento 2 - time picker on backend (xml form)How to overwrite System.xml?Magento 2 Pattern Library — Date & Time SelectorsHTTP 500 Error in System ConfigurationMagento 2 - time picker on backend (xml form)Magento 2 Add Datetime picker in system.xmlDate Time picker and time zone woesHow to implement Single Date and Time Picker in Magento 2Custom Module for Custom Column using Plugin Yes/No optionMagento 2 DateTime picker - Limit time selection rangeMagento2 UI Component admin Grid / Listing stuck loading