diff --git a/modules/boonex/ads/classes/BxAdsFormEntry.php b/modules/boonex/ads/classes/BxAdsFormEntry.php index 6fc7ad59c8..c441c3d784 100644 --- a/modules/boonex/ads/classes/BxAdsFormEntry.php +++ b/modules/boonex/ads/classes/BxAdsFormEntry.php @@ -84,8 +84,8 @@ public function __construct($aInfo, $oTemplate = false) function getCode($bDynamicMode = false) { - $this->_oModule->_oTemplate->addJs('entry.js'); - return $this->_oModule->_oTemplate->getJsCode('entry') . parent::getCode($bDynamicMode); + $sInclude = $this->_oModule->_oTemplate->addJs(array('entry.js'), $bDynamicMode); + return ($bDynamicMode ? $sInclude : '') . $this->_oModule->_oTemplate->getJsCode('entry') . parent::getCode($bDynamicMode); } function initChecker ($aValues = array (), $aSpecificValues = array()) diff --git a/modules/boonex/ads/classes/BxAdsModule.php b/modules/boonex/ads/classes/BxAdsModule.php index 7765e68149..c22d7a5a48 100644 --- a/modules/boonex/ads/classes/BxAdsModule.php +++ b/modules/boonex/ads/classes/BxAdsModule.php @@ -26,6 +26,18 @@ function __construct(&$aModule) )); } + public function actionGetCategoryForm() + { + if(bx_get('category') === false) + return echoJson(array()); + + return echoJson(array( + 'content' => $this->serviceEntityCreate(array( + 'dynamic_mode' => true + )) + )); + } + public function actionInterested() { $CNF = &$this->_oConfig->CNF; diff --git a/modules/boonex/ads/js/entry.js b/modules/boonex/ads/js/entry.js index ff080bc4ae..5d1f29fede 100644 --- a/modules/boonex/ads/js/entry.js +++ b/modules/boonex/ads/js/entry.js @@ -39,9 +39,31 @@ BxAdsEntry.prototype.interested = function(oElement, iContentId) { }; BxAdsEntry.prototype.onChangeCategory = function(oElement) { + var $this = this; + this.loadingInBlock(oElement, true); - document.location = bx_append_url_params(document.location.href, {category: $(oElement).val()}); + jQuery.get ( + this._sActionsUrl + 'get_category_form', + { + category: $(oElement).val() + }, + function(oData) { + if(oElement) + $this.loadingInBlock(oElement, false); + + if(!oData || !oData.content && oData.content.length == 0) + return; + + var oContent = $(oData.content); + var sFormId = oContent.filter('form').attr('id'); + if(!sFormId) + return; + + $('#' + sFormId).replaceWith(oContent); + }, + 'json' + ); }; BxAdsEntry.prototype.loadingInButton = function(e, bShow) {