Getting name and value of elem on selectionRemoved

Andrew's Avatar

Andrew

26 May, 2010 11:32 AM

On my search form I take the name and value of each selection and display it in a separate box on the page with resultClick so the user can see a summary of a complicated search form.

Now I need to remove the values from that box with selectionRemoved but I can't retrieve the name or value of the option removed.

I have tried:

selectionRemoved: function(elem){ alert(elem.value); }

but it comes back undefined. I've have also tried elem.attributes.value as this works on resultClick, but still no joy.

Any help would be greatly appreciated.

  1. 1 Posted by Sean on 11 Aug, 2010 07:33 AM

    Sean's Avatar

    Hey Guys,
    I'm having the same problem. Every time I insert :

    selectionAdded: function(elem){ alert(elem); }

    i get undefined or [object,Object]
    this is very important. Drew any input would be appreciated thanks in advance--Sean

    heres my full code :

    `

    $().ready(function() {
    
        $(function(){
            $("#category").autoSuggest("obtain_style.php", {selectedItemProp: "name", selectedValuesProp: "value", searchObjProps: "name", minChars: 2, matchCase: false,   
            selectionAdded: function(elem, data){
            alert(elem);
    
            }});
        });
    });

    `

  2. 2 Posted by StéphaneL on 27 Sep, 2010 09:40 PM

    StéphaneL's Avatar

    In Version 1.4, just add "data" value on :
    L169 : opts.selectionRemoved.call(this, org_li.prev()); by opts.selectionRemoved.call(this, data,org_li.prev());
    L336 :opts.selectionRemoved.call(this,item); by opts.selectionRemoved.call(this, data,item);

    Once is done, you can set :
    selectionRemoved: function(data,elem){
    console.log(data.name);
    console.log(elem);
    }

    Hope, this will be helpfull.

    S.

  3. 3 Posted by Mike on 17 Jan, 2011 11:17 PM

    Mike's Avatar

    Hi,

    By modifying the code for what Stéphane said, data will contain the data return by the query (or the preFill) which is an array of data.

    If you want the 'data' of the elem that is under deletion, you need another workaround.

    Mike

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