Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chau 66 posts 97 karma points
    Oct 09, 2009 @ 01:28
    Chau
    0

    autocomplete

    Does anyone know of an xslt autocomplete feature similar to google's homepage that searches through the nodes?

    And if you don't know of one, how would you go about making one?

  • Chau 66 posts 97 karma points
    Oct 09, 2009 @ 01:30
    Chau
    0

    Something like the http://umbraco.org/documentation/books page would be groovy but I can't find anything...

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Oct 09, 2009 @ 01:44
    Nik Wahlberg
    0

    Hi Chau, this functionality is actually available in Umbraco by utilizing the Ultimate Picker datatype. Take a look under Developers/Data Types in your Umbraco installation.

    -- Nik

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Oct 09, 2009 @ 09:25
    Jesper Ordrup
    4

    Hi Chau,

    I assume it's for your website frontend and not for Umbraco Admin.

    There's at least 2 good ways of doing this:

    • the Umbraco Base+jQuery way
      requires you to now the ways of .net coding
    • the XSLT + jQuery way

    Also .. you could go and do a usercontrol but that seems like overkill when all you do is retrieve information.

    The XSLT + jQuery way you'll need to:

    1. Create an xslt file that renderes the output by traversing some umbraco nodes. Just let it return the markup fragment you need. Like <ul>...</ul>. Make the macro accept a parameter and let your code filter the nodes on this.

    2. Add this macro to a template, example "ajaxsearch"

    3. Create another template that should render your page. You could use the runway textpage. Add jquery reference,  a input field with id and name = "searchid", a div tag with id ="resultid" and for example a <a href tag with id="submitid" or something else to attach a click event to. Like this:

    <input id="searchid" name="searchid" value=""></input>

    <a href="#" id="resultid">Go for it</a>

    <hr/>

    <div id="resultid"></div>

    4. Throw in this code in the template (or move it to an external js file):


      <script>
      $(document).ready(function(){

    var _mybutton = $('#submitid'); //


        _mybutton.click(function(){

                var _this = this;
                var _searchid = $('#searchid').val();
                var _result = $('#resultid');


                $.ajax({
                    url: "/ajaxsearch.aspx",
                    data: "search="+_searchid,
                    success: function(msg){

                    _result.html(msg);


                    }
                });

            return false;
        });

      });
      </script>

    Try it :-)

    /Jesper

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Oct 09, 2009 @ 09:30
    Jesper Ordrup
    0

    ... of couse this will only render the result below in a <ul></ul> structure but that will get you started.

    /Jesper

  • Chau 66 posts 97 karma points
    Oct 12, 2009 @ 03:12
    Chau
    0

    Hey thanks Jesper. Can this be done with an ahsx page too?

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Oct 15, 2009 @ 15:25
    Jesper Ordrup
    0

    Sure can, but why .-)

     

     

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Oct 15, 2009 @ 16:10
    Thomas Höhler
    0

    It's faster...

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 26, 2009 @ 09:02
    Jonas Eriksson
    0

    Is it really faster? How much overhead will the umbraco-rendering of a simple page like this have?

    I tried showing umbdebugshowtrace on my ajax-page of this kind. No overhead to mention at all. And the ajax-request to run a ordinary select on the db and get the results back took 35 ms according to firebug.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Oct 27, 2009 @ 13:48
    Thomas Höhler
    0

    In principle it is faster, but you are right: if you don't have any overhead the difference isn't really big.

Please Sign in or register to post replies

Write your reply to:

Draft