Javascript AJS append call

Scheibli Márk August 2, 2017

Hi!

I want to put a label to the operations-delete section but with AJS append call. My code is the following at the moment, but the label not appearing under the delete button:

AJS.$('#operations-delete').append('<li class="aui-list-item"><a href="#" id="my_web_item_link" tabindex="-1"><span class="trigger-label">Push me</span></a></li>');

Can you help me with this? I dont know what the concrete attributes are to write before the append section.

1 answer

1 accepted

0 votes
Answer accepted
Thor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 12, 2017

You don't have to use the AJS...

 

Just do it like:

$('#operations-delete').append("<div>Something</div>");

 

BTW:

You can use your Web Developer tools in Chrome / Firefox to debug javascript. Open it and propably you'll see an error in a case like this.

Often you just use the wrong scope / timing in JS and something is "undefined" at the time it should be executed.

Scheibli Márk August 15, 2017

Thank your very much! It was'nt that easy but with your function calling i could solve my problem. Here is my latest version of the code:

$('#opsbar-operations_more_drop').append('<div class="aui-dropdown2-section"><ul><li class="aui-list-item"><a href="#" id="listDialog"><span class="trigger-label">PD rendering</span></a></li></ul></div>');
Thor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 15, 2017

Your welcome & thanks for sharing your latest version :-)

Suggest an answer

Log in or Sign up to answer