I have an html component that includes some javascript.
A component is a file in the template engine, so you can use it
- in the initial rendering of the entire html page
- as standalone html created using ajax request
javascript should be applied to the object in the template, i.e.:
<div class="grid" > <div class="item" id="item_13"> This is item 13 </div> <div class="item" id="item_14"> This is item 14 </div> </div> <script type="text/javascript"> $(document).ready(function(){ $(HOW_DO_I_GET_PREVIOUS_ELEMENT???).someEffect(params) }) </script>
I checked this similar question , but the best answers seem to rely on the current script being the last in the 'scripts' variable, as the next they are not loaded yet. If I add html and js using an ajax request, this will not be the case.
To be 100% understandable: the question of getting the previous object WITHOUT reference to any particular attribute: there is no unique identifier for the tag, no random identifier, since theoretically there is always the possibility that it will be displayed twice, there is no unique attribute class, since exactly the same component can be displayed in another part of the HTML document.
Lucas t
source share