autosuggest not posting values

Kevin's Avatar

Kevin

21 Apr, 2012 10:29 PM

I have a modal popup that loads an iframe where the autosuggest enabled field is located. Autosuggest works, I am able to preFill, I have a custom format with images but I cannot get the selected values to $_POST. I ending up writing a script that will add form fields with each item clicked but this gets messy when the user decides to remove their selected values.

Form submission is handled with ajax and the fact that it is an iframe seems to have no bearing is it works when directly accessed.

What I'm do?

  1. 1 Posted by Kevin on 21 Apr, 2012 10:45 PM

    Kevin's Avatar

    Also wanted to add that aside from the occasional bug this is a great plugin. Here is some code showing my autosuggest setup.

    var current_prodz = {$current_prodz};
    $("#linked_prodz").autoSuggest("../func/link_prodz.php", {

        minChars: 3,
        startText: "What products do you carry?",
        selectedValuesProp: "value",
        selectedItemProp: "name",
        searchObjProps: "name",
        preFill: current_prodz,
        formatList: function(data, elem){
    
        var the_title = data.name;
        var the_id = data.value;
        var is_product = data.is_product;
        var photo_url = data.photo_url;
        var the_output = '<img src="/images/product/'+photo_url+'_40x40" width="40" height="40" alt="'+the_id+'" /><span>'+the_title+'</span>';
        var new_elem = elem.html(the_output);
        return new_elem;
        }       
        ,       
        resultsComplete: function(){
            $.scrollTo( '.as-results', 333 );           
            }
    
        ,
        resultClick: function(data){
            var the_id = $(this).find('img').attr('alt');
            var new_value = "<input name='linked_prodz_val[]' value='"+the_id+"' type='hidden' />";
    
            $('#linked_prodz_wrap').append(new_value);
    
        }
    
    });
    

    `

  2. 2 Posted by Kevin on 21 Apr, 2012 11:13 PM

    Kevin's Avatar

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