Expand my Community achievements bar.

SOLVED

How to add query parameters taken from author to url?

Avatar

Level 3
 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

In your sightly html of the component add the below attribute in your component div tag

Am setitng default value as 10. "perpage" is the property you set in dialog

<div class="mycomponent" data-sly-attribute.data-perpage="${ properties.perpage ? properties.perpage : '10' }">
</div>


In your java script , you can read this simple jquery selector

<script>
var perpage = $(".mycomponent").attr("perpage");
//Make a XHR call with perpage value
</script>

View solution in original post

4 Replies

Avatar

Community Advisor

Could you please elaborate more to help?

Avatar

Level 3

I want to add some query parameters to url dynamically. Need to take it from author through dialog and then pass the accessed values as parameters to url with the help of ajax call and Post methods.

For example:

Number of results to be displayed per page have to be taken from author and passed to url as query parameter.

Avatar

Correct answer by
Community Advisor

In your sightly html of the component add the below attribute in your component div tag

Am setitng default value as 10. "perpage" is the property you set in dialog

<div class="mycomponent" data-sly-attribute.data-perpage="${ properties.perpage ? properties.perpage : '10' }">
</div>


In your java script , you can read this simple jquery selector

<script>
var perpage = $(".mycomponent").attr("perpage");
//Make a XHR call with perpage value
</script>

Avatar

Level 3

Also if possible can you elaborate how can the same attributes be passed to a servlet doPost method using javascript?