Forum Discussion

phoneboy's avatar
phoneboy
Director
5 years ago

jQuery not adding to input field

I have a custom component for the "new post" button that, in some spaces/pages, will add elements to the post URL for tags and labels.
I then have another custom component I've added on the New Post page that should, using jQuery, modify the lia-tags and lia-labels fields to add in the values from the URL.
It looks something like this:

<#assign tags = webuisupport.path.rawParameters.name.get("tags","")/>
<#assign labels = webuisupport.path.rawParameters.name.get("labels","")/>

<@liaAddScript>
  (function($) {
    $(document).ready(function() {
      $("#lia-tags").val("${tags}"); 
      $("#lia-labels").val("${labels}"); 
    });
  })(LITHIUM.jQuery);
</@liaAddScript>

However, the jQuery does not appear to be doing anything.
If I review the source code of the page, I can see my code there complete with the values I passed (or didn't) via the URL.

Am I missing anything here?  

  • phoneboy can you share your url example for tags and labels on the PostPage? BTW, when you embed freemarker into JS, better escape it like ${tags?js_string}

    And you can remove 

     

    $(document).ready

     

    Since  <@liaAddScript> already puts your code at the end of document. Try that first and see if it works.

    Otherwise please share the url example, I may be able to troubleshoot.

  • The URLs are fairly simple like:

    communityurl/t5/forums/postpage/interaction-style/blog/board-id/myboard/labels/Security Basics/tags/myTag

    That said, good call to escape them.
    And good call on the fix.

  • phoneboy can you share your url example for tags and labels on the PostPage? BTW, when you embed freemarker into JS, better escape it like ${tags?js_string}

    And you can remove 

     

    $(document).ready

     

    Since  <@liaAddScript> already puts your code at the end of document. Try that first and see if it works.

    Otherwise please share the url example, I may be able to troubleshoot.