(autocomplete) extraParams get hidden inputs
How do I put all the hidden inputs from the surrounding form into extraParams?
I'm a jquery noob so maybe I'm going about this all wrong.
This doesn't work.
- function getHiddens(obj) { console.log("processing params"); var array = new Array(); $(obj).parents('form:first').children('[type=hidden]').each(function () { console.log(this['name']); array[this['name']] = this['value']; }); return array; }
- function getHiddens(obj) { console.log("processing params"); var array = new Array(); $(obj).parents('form:first').children('[type=hidden]').each(function () { console.log(this['name']); array[this['name']] = this['value']; }); return array; }
- $(".auto").autocomplete("search.php?returnType=json",{
- dataType: "json",
- minChars: 3,
- autoFill: true,
- extraParams: getHiddens(this),
- parse: function(data) {
- var array = new Array();
- for(var i=0;i<data.length;i++)
- {
- array[array.length] = { data: data[i], value: data[i]['title'], result: data[i]['title'] };
- }
- return array;
- },
- formatItem: function(row) {
- return row['title'];
- }
- });
- $(".auto").autocomplete("search.php?returnType=json",{
- dataType: "json",
- minChars: 3,
- autoFill: true,
- extraParams: getHiddens(this),
- parse: function(data) {
- var array = new Array();
- for(var i=0;i<data.length;i++)
- {
- array[array.length] = { data: data[i], value: data[i]['title'], result: data[i]['title'] };
- }
- return array;
- },
- formatItem: function(row) {
- return row['title'];
- }
- });