We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13306
    • 19 Posts
    Hi,

    Could anyone tell me a good way to use both the ajax and non-ajax modes of the ajaxsearch snippet (on the same page)? I like the features of the ajax mode, but, of course, I can’t count on everyone having javascript enabled. I need the site I’m working on to fall back to the non-ajax mode where javascript isn’t available.

    I’d usually achieve this kind of thing (outside of a CMS) (I’d call it graceful degradation) by replacing non-javascript content with the javascript equivalent with javascript (if you follow*), perhaps with a ref to an element’s innerHTML property, but I don’t think i can do that here. *ie, if jscript isn’t available, the non-jscript version doesn’t get replaced.

    I’m very new to modx. (Very nice software - I’ve already recommended it to others). I’m sure this will have come up before, but I can’t seem to find a similar post.

    Thanks very much!


    Ps:
    I hope this post is in the right forum - please forgive me if it isn’t. I’m new here.

    Thanks again.
      • 5811
      • 1,717 Posts
      The using of the ajax and the non-ajax mode will be better managed with the next release (1.9.0). You could see two demos about this subject:

      http://www.modx2.wangba.fr/index.php?id=221 and http://www.modx2.wangba.fr/index.php?id=223

      With the 1.8.4 release, unfortunately when you disable javascript, the div output_results is visible. This issue is now corrected with 1.9.0 release in progress (the beta doesn’t correct this issue).
      For instance try it on this page (with jquery): http://www.modx.wangba.fr/index.php?id=353 Search something like "mon" or "ton" or ...

      To correct this you need to change the ajaxSearch code (Php and js) ...
        • 13306
        • 19 Posts
        Hi

        Thanks for the reply and thanks for the links. I would quite like to find a workaround for this and I’m not sure I can wait for a new release.

        Would you mind helping me with some insight into the way this works?

        Am i right in thinking that if the ajaxSearch boolean is set to true, the server side (php) search functionality is disabled?

        Is there an easy way to prevent that? I’m quite comfortable making changes to the code, but I’m struggling to decipher it all - there are a lot of includes.


        Quote from: coroico at Mar 04, 2010, 05:21 PM

        With the 1.8.4 release, unfortunately when you disable javascript, the div output_results is visible.
        Is it visible but without any content? That seems only to be a problem for me in IE6 with my current css. (An old quirk in IE6 where minimum div height is set to the line height (even with no content) - I’ve often got round that with other stuff (e.g. spacers) by setting line-height or font-size to 0).

        I can stand a few layout issues for the few people who may be in IE6 with no jscript.
          • 5811
          • 1,717 Posts
          I would quite like to find a workaround for this and I’m not sure I can wait for a new release.
          I can understand this. On my side I prefer now spend time to deliver the next release quickly than investigate for a workaround on an older release.

          Am i right in thinking that if the ajaxSearch boolean is set to true, the server side (php) search functionality is disabled?
          Not at all. The ajaxSearch boolean defines the mode ajax-mode (which requires javascript) and non-ajax mode. Nothing to see with the disabling of the search.

          That seems only to be a problem for me in IE6 with my current css
          Not only for IE 6 but also for firefox 3.6
            • 13306
            • 19 Posts
            Quote from: coroico
            On my side I prefer now spend time to deliver the next release quickly than investigate for a workaround on an older release.
            Fair enough.

            I spent the whole evening trying to find an easy fix. I’d almost given up. If you’re interested, in the end, i just commented out this line //$this->varLayout[’results’] = OUTPUT_ID; in ajaxSearch.class.inc.php and added <div id="ajaxSearch_output"></div> manually to my template.

            Am i right in thinking that if the ajaxSearch boolean is set to true, the server side (php) search functionality is disabled?
            Not at all. The ajaxSearch boolean defines the mode ajax-mode (which requires javascript) and non-ajax mode. Nothing to see with the disabling of the search.
            It kind of does disable the non-ajax mode, you know. $this->varLayout[’results’] = OUTPUT_ID; replaces the non-ajax results (whether or not jscript is available in the browser).

            Of course you know - did you write this?

            Very nice software. Thank you.