A
A
Alexander Sinitsyn2016-03-22 20:24:07
1C-Bitrix
Alexander Sinitsyn, 2016-03-22 20:24:07

How to make an ajax update of the directory when the selected properties of the smart filter change?

The filter is "INSTANT_RELOAD" => "Y",
According to the script it should be here

if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID)
{
  var url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
  BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
}

But both conditions do not work at all ...
In the component, bxajaxid is looking for this, I tried to do it through
$bxajaxid = CAjax::GetComponentID($component->__name, $component->__template->__name);

but the catalog template and smart filter result in different values.
Kick in the right direction.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-03-22
@gangstarcj

That's what I did

JCSmartFilter.prototype.postHandler = function (result)
{ 

  if(result.ITEMS)
  {
    for(var PID in result.ITEMS)
    {
      var arItem = result.ITEMS[PID];
      if(arItem.PROPERTY_TYPE == 'N' || arItem.PRICE)
      {
      }
      else if(arItem.VALUES)
      {
        for(var i in arItem.VALUES)
        {
          var ar = arItem.VALUES[i];
          var control = BX(ar.CONTROL_ID);
          if(control)
          {
            control.parentNode.className = ar.DISABLED? 'lvl2 lvl2_disabled': 'lvl2';
          }
        }
      }
    }
    var modef = BX('modef');
    var modef_num = BX('modef_num');
    if(modef && modef_num)
    {
      result.INSTANT_RELOAD = "Y";
      
      modef_num.innerHTML = result.ELEMENT_COUNT;
      var hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true);

      if(result.FILTER_URL && hrefFILTER)
        hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL);

      if(result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID)
      {
        BX.bind(hrefFILTER[0], 'click', function(e)
        {
          var url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
          BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
          return BX.PreventDefault(e);
        });
      }
      
      
      result.INSTANT_RELOAD = "Y";
      result.COMPONENT_CONTAINER_ID = "catalog_section";

      console.log(result.COMPONENT_CONTAINER_ID);
      console.log(result.INSTANT_RELOAD);
      if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID)
      {
        var url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
        console.log(url);
        //url = url + "&bxajaxid=" + result.COMPONENT_CONTAINER_ID;
        console.log(url);
        //BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
        $( ".category" ).load( url + " .category");
        //$( ".category > .right .gallery" ).load( url + " .gallery > li");
      }
      else
      {
        if(modef.style.display == 'none')
          modef.style.display = 'block';
        modef.style.top = this.position.top + 'px';
      }
    }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question