JQuery append element removes all html dom elements

浪子不回头ぞ 提交于 2019-12-11 23:39:03

问题


I have a filter system setup and I'm struggling with jquery .append.

When the user interacts with the filter system, the visible results are removed from the dom and then distributed evenly in <div class="col-1"> ... <div class="col-2">... <div class="col-3">...

It's done this way because the page outputs staff in a vertical manner, but the filtering must reorder horizontally. You'll see what I mean when you use the first filter.

Please view this page: demo page

  1. Click on Event Sponsor
  2. Then click on East

The function that I'm talking about is reflowVisibleResults() Basically visible results are copied to an array and then removed from the document only to be then reflowed left to right in col-1,col-2,col-3

The whole page is replaced with just a phone number. If you go to line 917 and switch the above line over it works as expected. I just can't figure out how to actually output html from an array of jquery objects.


回答1:


Agree with Parker, you code seems way overcomplicated for what it needs to be. Here is quick sample of how I would do it.

I am sure it can be optimized and polished quiet a bit, but that should be enough to get you on the right path.




回答2:


it seems to me that you are over complicating the problem. i created a filter system similar to this but i used jQuery .filter() or .not() methods to achieve the results.

It only took me two lines of jquery to create the filtering system.



来源:https://stackoverflow.com/questions/8453032/jquery-append-element-removes-all-html-dom-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!