Hi all
Maybe someone can point me in the right direction here.
I've created a new component, which has a button that shows some text and a button that hides it again.
The component works fine and it imports as it should in the AT.
However if I try put more than one of this component on a page, it is only the first one that works. It is always, the first one of the components that works and the second, third, fourth, and so on, never work.
I've started out with the text-component and added code to it.
Is it because I'm using jQuery code directly in the .js file of the component?
Can someone point me in the right direction? What do I have to learn in order to understand, why it doesn't work? Should I delete the Javacode I have written already and use Handlebars instead? Or is it something else?
Any help will be greatly appreciated.
Thanks!
Henrik Aabom
My .hbs-code:
<div class="text-inner component-inner" role="region" aria-label="{{_globals._components._text.ariaRegion}}">
{{> component this}}
<div id="moreTxt" class="mynewdiv">
<p>{{{moreText}}}</p>
<button id="btnHide" type="button">{{{lessText_btn}}}</button>
</div>
<div id="lessTxt"><button id="btnShow" type="button">{{{moreText_btn}}}</button></div>
</div>
My .js-code:
In the postRender: function() I have put the code:
$("#moreTxt").hide();
And in the inview: function I have put:
$("#btnHide").click(function(){
$("#moreTxt").hide(1000);
$("#lessTxt").show(1000);
});
$("#btnShow").click(function(){
$("#moreTxt").show(1000);
$("#lessTxt").hide(1000);
});