Mashiane Expert Licensed User Longtime User Dec 5, 2024 #1 Hi Currently we are appending items with LoadLayoutArray. I want to add items at the top of my list and not at the bottom. Is there a way I can do this? Thanks in advance.
Hi Currently we are appending items with LoadLayoutArray. I want to add items at the top of my list and not at the bottom. Is there a way I can do this? Thanks in advance.
Solution alwaysbusy Dec 5, 2024 you can try wrapping each item in some kind of div and load the layout on that. This way you can insert such a wrap div before the others and then load the layout to it. something like: Code: Copy <div id="mainlist"> <div id=""> ... add such a div before the others and load the new layout </div> <div id=""> ... already loaded </div> <div id=""> ... already loaded </div> </div> Alwaysbusy
you can try wrapping each item in some kind of div and load the layout on that. This way you can insert such a wrap div before the others and then load the layout to it. something like: Code: Copy <div id="mainlist"> <div id=""> ... add such a div before the others and load the new layout </div> <div id=""> ... already loaded </div> <div id=""> ... already loaded </div> </div> Alwaysbusy
alwaysbusy Expert Licensed User Longtime User Dec 5, 2024 #2 you can try wrapping each item in some kind of div and load the layout on that. This way you can insert such a wrap div before the others and then load the layout to it. something like: Code: Copy <div id="mainlist"> <div id=""> ... add such a div before the others and load the new layout </div> <div id=""> ... already loaded </div> <div id=""> ... already loaded </div> </div> Alwaysbusy Upvote 1 Solution
you can try wrapping each item in some kind of div and load the layout on that. This way you can insert such a wrap div before the others and then load the layout to it. something like: Code: Copy <div id="mainlist"> <div id=""> ... add such a div before the others and load the new layout </div> <div id=""> ... already loaded </div> <div id=""> ... already loaded </div> </div> Alwaysbusy
Mashiane Expert Licensed User Longtime User Dec 5, 2024 #3 Perfect, this will work well on first load. Will do it like that. Thank you so much. Another question, when it comes to SSE and the list has to be updated after a particular event by just adding 1 item on the top without having to clear the list? what could be the best approach? Upvote 0
Perfect, this will work well on first load. Will do it like that. Thank you so much. Another question, when it comes to SSE and the list has to be updated after a particular event by just adding 1 item on the top without having to clear the list? what could be the best approach?
alwaysbusy Expert Licensed User Longtime User Dec 5, 2024 #4 Maybe .prepend() instead of .append() is what you are looking for? You would use that to add the item 'wrap' div at the beginning of the div 'mainlist'. Last edited: Dec 5, 2024 Upvote 0
Maybe .prepend() instead of .append() is what you are looking for? You would use that to add the item 'wrap' div at the beginning of the div 'mainlist'.
Mashiane Expert Licensed User Longtime User Dec 6, 2024 #5 alwaysbusy said: Maybe .prepend() instead of .append() is what you are looking for? You would use that to add the item 'wrap' div at the beginning of the div 'mainlist'. Click to expand... Tested with prepend, works perfectly. Just need to figure out how to move items to the top of the list based on content change, more like how whatsapp works when a new message arrives and a chat moves up. Thanks. Upvote 0
alwaysbusy said: Maybe .prepend() instead of .append() is what you are looking for? You would use that to add the item 'wrap' div at the beginning of the div 'mainlist'. Click to expand... Tested with prepend, works perfectly. Just need to figure out how to move items to the top of the list based on content change, more like how whatsapp works when a new message arrives and a chat moves up. Thanks.