Why is my return empty from jQuery to Velocity?











up vote
0
down vote

favorite












I am working on an add-on for Confluence. I am using Apache Velocity and Js.
When I print out my template, I get no return from my JS file where I am using jQuery. How can I establish the communication between those two correctly? Thank you!



My JS



jQuery(function ($) {
var initmyConfluenceMacro = function ()
{
$(".myConfluenceMacro").each(function()
{
var html = "wadup";
var dayDates = $(this).find("input.dayDates").val();
html = html + dayDates;
$(this).html(html);
});
};
$(document).ready(function()
{
initmyConfluenceMacro();
});
});


MY Velocity Template.vm



#requireResource("confluence.web.resources:jquery")
#requireResource("com.atlassian.tutorial.myConfluenceMacro:myConfluenceMacro-resources")

My variables : $myCustomVar
My variable js:

<div class="myConfluenceMacro">
<fieldset class="parameters hidden">
<input type="hidden" class="dayDates" value="YO! Was up dude?">
</fieldset>
</div>









share|improve this question






















  • There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
    – Pointy
    Nov 19 at 15:24










  • @Pointy making sure it is really ready
    – epascarello
    Nov 19 at 15:26






  • 3




    You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
    – epascarello
    Nov 19 at 15:27








  • 1




    Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
    – Pointy
    Nov 19 at 15:34






  • 1




    Are you viewing the resulting content in a browser? That's where console.log() goes.
    – Pointy
    Nov 19 at 15:55















up vote
0
down vote

favorite












I am working on an add-on for Confluence. I am using Apache Velocity and Js.
When I print out my template, I get no return from my JS file where I am using jQuery. How can I establish the communication between those two correctly? Thank you!



My JS



jQuery(function ($) {
var initmyConfluenceMacro = function ()
{
$(".myConfluenceMacro").each(function()
{
var html = "wadup";
var dayDates = $(this).find("input.dayDates").val();
html = html + dayDates;
$(this).html(html);
});
};
$(document).ready(function()
{
initmyConfluenceMacro();
});
});


MY Velocity Template.vm



#requireResource("confluence.web.resources:jquery")
#requireResource("com.atlassian.tutorial.myConfluenceMacro:myConfluenceMacro-resources")

My variables : $myCustomVar
My variable js:

<div class="myConfluenceMacro">
<fieldset class="parameters hidden">
<input type="hidden" class="dayDates" value="YO! Was up dude?">
</fieldset>
</div>









share|improve this question






















  • There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
    – Pointy
    Nov 19 at 15:24










  • @Pointy making sure it is really ready
    – epascarello
    Nov 19 at 15:26






  • 3




    You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
    – epascarello
    Nov 19 at 15:27








  • 1




    Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
    – Pointy
    Nov 19 at 15:34






  • 1




    Are you viewing the resulting content in a browser? That's where console.log() goes.
    – Pointy
    Nov 19 at 15:55













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am working on an add-on for Confluence. I am using Apache Velocity and Js.
When I print out my template, I get no return from my JS file where I am using jQuery. How can I establish the communication between those two correctly? Thank you!



My JS



jQuery(function ($) {
var initmyConfluenceMacro = function ()
{
$(".myConfluenceMacro").each(function()
{
var html = "wadup";
var dayDates = $(this).find("input.dayDates").val();
html = html + dayDates;
$(this).html(html);
});
};
$(document).ready(function()
{
initmyConfluenceMacro();
});
});


MY Velocity Template.vm



#requireResource("confluence.web.resources:jquery")
#requireResource("com.atlassian.tutorial.myConfluenceMacro:myConfluenceMacro-resources")

My variables : $myCustomVar
My variable js:

<div class="myConfluenceMacro">
<fieldset class="parameters hidden">
<input type="hidden" class="dayDates" value="YO! Was up dude?">
</fieldset>
</div>









share|improve this question













I am working on an add-on for Confluence. I am using Apache Velocity and Js.
When I print out my template, I get no return from my JS file where I am using jQuery. How can I establish the communication between those two correctly? Thank you!



My JS



jQuery(function ($) {
var initmyConfluenceMacro = function ()
{
$(".myConfluenceMacro").each(function()
{
var html = "wadup";
var dayDates = $(this).find("input.dayDates").val();
html = html + dayDates;
$(this).html(html);
});
};
$(document).ready(function()
{
initmyConfluenceMacro();
});
});


MY Velocity Template.vm



#requireResource("confluence.web.resources:jquery")
#requireResource("com.atlassian.tutorial.myConfluenceMacro:myConfluenceMacro-resources")

My variables : $myCustomVar
My variable js:

<div class="myConfluenceMacro">
<fieldset class="parameters hidden">
<input type="hidden" class="dayDates" value="YO! Was up dude?">
</fieldset>
</div>






javascript jquery velocity confluence






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 15:23









TeslaX

449




449












  • There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
    – Pointy
    Nov 19 at 15:24










  • @Pointy making sure it is really ready
    – epascarello
    Nov 19 at 15:26






  • 3




    You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
    – epascarello
    Nov 19 at 15:27








  • 1




    Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
    – Pointy
    Nov 19 at 15:34






  • 1




    Are you viewing the resulting content in a browser? That's where console.log() goes.
    – Pointy
    Nov 19 at 15:55


















  • There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
    – Pointy
    Nov 19 at 15:24










  • @Pointy making sure it is really ready
    – epascarello
    Nov 19 at 15:26






  • 3




    You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
    – epascarello
    Nov 19 at 15:27








  • 1




    Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
    – Pointy
    Nov 19 at 15:34






  • 1




    Are you viewing the resulting content in a browser? That's where console.log() goes.
    – Pointy
    Nov 19 at 15:55
















There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
– Pointy
Nov 19 at 15:24




There's no reason to nest a $(document).ready() setup when you're already inside a "ready" handler.
– Pointy
Nov 19 at 15:24












@Pointy making sure it is really ready
– epascarello
Nov 19 at 15:26




@Pointy making sure it is really ready
– epascarello
Nov 19 at 15:26




3




3




You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
– epascarello
Nov 19 at 15:27






You need to debug and find out why it is not being found. My guess is something gets loaded dynamically and you are trying to look for it before it is on the page. console.log and debugger are your friend.
– epascarello
Nov 19 at 15:27






1




1




Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
– Pointy
Nov 19 at 15:34




Well one thing you can to do investigate is console.log($(".myConfluenceMacro").length) before the .each() call. That'll tell you if the DOM contains any instances of the macro contents after expansion.
– Pointy
Nov 19 at 15:34




1




1




Are you viewing the resulting content in a browser? That's where console.log() goes.
– Pointy
Nov 19 at 15:55




Are you viewing the resulting content in a browser? That's where console.log() goes.
– Pointy
Nov 19 at 15:55












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










I managed it. Like this, it is working, and I get the HTML back!



JS



$(document).ready(function(){
$(".myConfluenceMacro").each(function(){
$(this).html("Hello <b>world!</b>");
});
});


VELOCITY



<script type="text/javascript">
#include( "templates/currencyDetail.js")
</script>
<body>

<div class="myConfluenceMacro">

</div>





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53377745%2fwhy-is-my-return-empty-from-jquery-to-velocity%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    I managed it. Like this, it is working, and I get the HTML back!



    JS



    $(document).ready(function(){
    $(".myConfluenceMacro").each(function(){
    $(this).html("Hello <b>world!</b>");
    });
    });


    VELOCITY



    <script type="text/javascript">
    #include( "templates/currencyDetail.js")
    </script>
    <body>

    <div class="myConfluenceMacro">

    </div>





    share|improve this answer

























      up vote
      0
      down vote



      accepted










      I managed it. Like this, it is working, and I get the HTML back!



      JS



      $(document).ready(function(){
      $(".myConfluenceMacro").each(function(){
      $(this).html("Hello <b>world!</b>");
      });
      });


      VELOCITY



      <script type="text/javascript">
      #include( "templates/currencyDetail.js")
      </script>
      <body>

      <div class="myConfluenceMacro">

      </div>





      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        I managed it. Like this, it is working, and I get the HTML back!



        JS



        $(document).ready(function(){
        $(".myConfluenceMacro").each(function(){
        $(this).html("Hello <b>world!</b>");
        });
        });


        VELOCITY



        <script type="text/javascript">
        #include( "templates/currencyDetail.js")
        </script>
        <body>

        <div class="myConfluenceMacro">

        </div>





        share|improve this answer












        I managed it. Like this, it is working, and I get the HTML back!



        JS



        $(document).ready(function(){
        $(".myConfluenceMacro").each(function(){
        $(this).html("Hello <b>world!</b>");
        });
        });


        VELOCITY



        <script type="text/javascript">
        #include( "templates/currencyDetail.js")
        </script>
        <body>

        <div class="myConfluenceMacro">

        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 11:38









        TeslaX

        449




        449






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2fstackoverflow.com%2fquestions%2f53377745%2fwhy-is-my-return-empty-from-jquery-to-velocity%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

            Create new schema in PostgreSQL using DBeaver

            Deepest pit of an array with Javascript: test on Codility

            Costa Masnaga