Code fix to easily extend the object and events

Roberto's Avatar

Roberto

23 Jan, 2013 03:23 PM

I changed the following code:
var formatted = $('

').click(function(){

To this:
var formatted = $('

').click(function(){

This way you can easily do on mouse hover the item and do cool stuff like adding an thumbnail.

var obj_suggest = $("#obj-1").autoSuggest(data.items, {

        asHtmlID:'123',//as-results-1
        minChars:2,
        selectedItemProp:"name",
        searchObjProps:"name",
        preFill:data_prefill,
        resultsComplete:function() {
            $('.as-result-item').hover(
                function () {
                    $(this).append($("<span> &nbsp; <img src='/backoffice/thumbs/"+ parseInt($(this).attr('data-id').replace(/[^0-9]/gi,'')) +".jpg' width='80' height='80' /></span>"));
                },
                function () {
                    $(this).find("span:last").remove();
                }
            );              
        }
    });
  1. 1 Posted by Roberto on 23 Jan, 2013 03:25 PM

    Roberto's Avatar

    ` //var formatted = $('

    ').click(function(){

    var formatted = $('

    ').click(function(){

    `

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac