0

i'm using ajax live search on my site. but it only works on the home page of my site.

after looking for its problem, i found out that a piece of js code that is supposed to load in , only loads when its home page. and that's why it doesn't work on other pages. i loaded it in tag mutually, and commented the function that is supposed to load it.

now i wanna find out why this function doesn't work right.. what should i do? has anyone had the same problem with ajax live search?

this is the function that has to load the js part in :

     //fix if user provide percent value for the result width
  if(strpos($searchresultwidth, "%") !== false) {
    $searchresultwidth = 2000;
    $dynamicresult = 1;
  }    
  $document->addScriptDeclaration("
  dojo.addOnLoad(function(){
      document.search = new AJAXSearch".$theme."({
        id : '".$module->id."',
        node : dojo.byId('offlajn-ajax-search".$module->id."'),
        searchForm : dojo.byId('search-form".$module->id."'),
        textBox : dojo.byId('search-area".$module->id."'),
        suggestBox : dojo.byId('suggestion-area".$module->id."'),
        searchButton : dojo.byId('ajax-search-button".$module->id."'),
        closeButton : dojo.byId('search-area-close".$module->id."'),
        searchCategories : dojo.byId('search-categories".$module->id."'),
        productsPerPlugin : $productsperplugin,
        dynamicResult : '$dynamicresult',
        searchRsWidth : $searchresultwidth,
        searchImageWidth : '".intval($params->get('imagew', 180))."',
        minChars : $minchars,
        searchBoxCaption : '$searchboxcaption',
        noResultsTitle : '$noresultstitle',
        noResults : '$noresults',
        searchFormUrl : '$searchformurl',
        enableScroll : '$scrolling',
        showIntroText: '$intro',
        scount: '$scount',
        lang: '".JRequest::getCmd('lang')."',
        stext: '$stext',
        moduleId : '$module->id',
        resultAlign : '$resultalign',
        targetsearch: '".$params->get('targetsearch', 0)."',
        linktarget: '".$params->get('linktarget', 0)."',
        keypressWait: '$keypresswait',
        catChooser : $catchooser,
        searchResult : $searchresult,
        seemoreEnabled : $seemoreenabled,
        seemoreAfter : $seemoreafter,
        keywordSuggestion : '".$keywordSuggestion."',
        seeMoreResults : '$seemoreresults',
        resultsPerPage : '".$params->get('resultsperpage', 4)."',
        resultsPadding : '".$params->get('resultspadding', 10)."',
        controllerPrev : '".JTEXT::_('SEARCH_PREV')."',
        controllerNext : '".JTEXT::_('SEARCH_NEXT')."',
        fullWidth : '1',
        resultImageWidth : '".$params->get('imagew', 180)."',
        resultImageHeight : '".$params->get('imageh', 140)."',
        showCat : '".$params->get('showcat', 1)."',
        voicesearch : '".$params->get('voicesearch', 0)."'
      })
    });"
  ); 

an important thing: on english side it works fine on all pages. but on persian language side (persian is a right to left lang) it works only on main page.

  • can you please share the code?? – Joomler Aug 4 '16 at 17:23
  • Are you using the same search module on all pages, or separate instances? – Michael Yaeger Aug 4 '16 at 17:40
  • i just added the code.. – kiasaty Aug 8 '16 at 5:53
  • im using it "on all pages" – kiasaty Aug 8 '16 at 5:54
  • have you checked console?? – Joomler Aug 8 '16 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.