Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Вот так регионы создаются в шаблоне
  2. <h5 style="margin-bottom: 10px;padding-bottom: 0px;padding-top:140px">Выберите регион</h5>
  3.     <ul class="nav nav-pills col-md-12" style="padding-bottom: 0px;padding-top:10px">
  4.         {% for region in regions %}
  5.            <li class="pill">
  6.                <a id="region-{{ region.id }}" class="pill-region" data-region="{{ region.id }}">
  7.                   {% if region.search_engine == 'G' %}
  8.                    Google-{{region}}
  9.                    {%else%}
  10.                    Яндекс-{{region}}
  11.                    {%endif%}
  12.                </a>
  13.            </li>
  14.        {% endfor %}
  15.     </ul>
  16.  
  17. //вот так обрабатывается клик по региону тоже в шаблоне в джс, проверила, клик работает
  18. $("#positions").on("click", ".pill-region", function(){
  19.         $(this).parent().toggleClass("active");
  20.     });
  21.  
  22. //вот так загружаем первый регион
  23. $('.pill:first-child a').click();
  24.  
  25. //вот так передаем данные на сервер (не работает)
  26. var regions=[]
  27.     $(".pill").each(function(){
  28.         if ($(this).hasClass("active")){
  29.             regions.push($(this).children().find(".pill-region").data("region_id"));
  30.             console.log($(this).children().find(".pill-region").data("region"));
  31.         }
  32.     });
  33.  
  34.     data = {};
  35.     data.regions = JSON.stringify(regions);
  36.     console.log(regions);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement