2

pLugin having popup Page with one Drop down List and one Submit button. now want to selected text from Dropdown list will pass in CMS text field.

Need to implement below Function in Main Command. Question : How i fetch the popup JS event listener value in my main Command ???????

execute: function (selection) {

  $evt.addEventHandler(p.popup, "submit", function (event)
 {
                   try {
                               var fieldBuilder;
                               var tabs = $display.getView().properties.controls.TabControl;
                               var cardCount, card;
                               cardCount = tabs.properties.cards.length;
                               card;
                               //  console.log($display.getView().properties.controls.TabControl);
                               while (cardCount--) {
                                   card = tabs.properties.cards[cardCount];
                                   if (card.getId() === "MetadataTab") {
                                       fieldBuilder = card.properties.controls.fieldBuilder;
                                       //console.log(fieldBuilder);
                                   }
                               }

                               if (fieldBuilder.getField("topic")) {

                                   ///Code For topic
                                   var set = fieldBuilder.getField("topic");

                                   var x = "someText";
                                   set.setValues([x.toString()]);
                                   console.log(fieldBuilder.getField("topic").getValues()[0]);
                               }

                               if (fieldBuilder.getField("subTopic")) {
                                   var set = fieldBuilder.getField("subTopic");

                                   var x = "sometext";
                                   set.setValues([x.toString()]);
                                   console.log(fieldBuilder.getField("subTopic").getValues()[0]);

                               }

                           }

                           catch (e) {
                               console.log("Found Error" + e);
                           }
                          // p.popup.close();
               });

I have implemented Selected DDl Value code in popUp Js as below

    controls.btnSelect.addEventListener("click", function () {

        var skillsSelect = document.getElementById("ddlTopic");
        var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;

        target.fireEvent("submit", { content: selectedText });
    });

need below content in Main command.js "Submit" handler Event. target.fireEvent("submit", { content: selectedText });

Thanks in Advanced!!!!!!

1

Here is the Code which i used to fetch the Submit Event of popupPage.js in Command.js

In popupPage.js we need to declare ._excecute Command as below

Alchemy4Tridion.Plugins.Topic.Views.Popup.prototype._execute = function (event) {

//logic of dropdown control

var Result =//logic Result;

target.fireEvent("submit", { content: Result });

});

Now fetch the Event and Result in Command.js.

execute: function (target) {

 $evt.addEventHandler(p.popup, "submit", function (event) {

//you will get your Result in event.data.content

var val = event.data.content;

});
} 

Happy Coding.....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.