Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Typeahead不读取初始页面加载后创建的属性_Jquery_Ajax_Bootstrap Typeahead - Fatal编程技术网

Jquery Typeahead不读取初始页面加载后创建的属性

Jquery Typeahead不读取初始页面加载后创建的属性,jquery,ajax,bootstrap-typeahead,Jquery,Ajax,Bootstrap Typeahead,我正在使用bootstrap-typeahead.jsv2.0.3和jqueryv1.7.2 我有一个表单,从引导模式加载,有两个文本框,需要使用typeahead 根据在第一个文本框中输入的数据,将向第二个框中添加两个属性:数据过滤器附加列和数据过滤器附加id属性(在上面的过滤器接口项中)。通过使用以下代码,可以完成此操作: $( document ).on( 'change', '#filter___hotspot_id', function () { var interface_f

我正在使用bootstrap-typeahead.jsv2.0.3和jqueryv1.7.2

我有一个表单,从引导模式加载,有两个文本框,需要使用typeahead

根据在第一个文本框中输入的数据,将向第二个框中添加两个属性:数据过滤器附加列和数据过滤器附加id属性(在上面的过滤器接口项中)。通过使用以下代码,可以完成此操作:

$( document ).on( 'change', '#filter___hotspot_id', function () {
    var interface_filter = $('#filter__interface');
    var id_parts = $( this ).val().split( ' id:' );
    interface_filter.attr('data-filter-additional-col', 'hotspot_id' );
    interface_filter.attr('data-filter-additional-id', id_parts[id_parts.length - 1] );
    // This is the call to a function to reload the code where the ajax call is below in this question:
    FUNC.typeahead.init();
});
最初加载页面时,将加载调用typeahead的ajax函数:

    $( p_field_obj )
        .typeahead({
            ajax: {
                url: 'ajax_handler.php?command=ajax-typeahead&tablename=' + 
                        $( p_field_obj ).attr( 'data-filter-tablename' ) + 
                        '&columnname=' + $( p_field_obj ).attr( 'data-filter-columnname' ) + 
                        '&context=' + $( p_field_obj ).attr( 'data-filter-context' ) +
                        '&additional_col=' + $(p_field_obj).attr('data-filter-additional-col') +
                        '&additional_id=' + $(p_field_obj).attr('data-filter-additional-id'),
                timeout: 300,
                triggerLength: 2,
                loadingClass: 'search_in_progress',
                preProcess: function( data ) {
                    retval = jQuery.parseJSON( data );
                    return retval;
                } 
            },
            matcher: function( item ) { return item; },  // Stops the client filtering the results coming back from AJAX.
            items: 999  // We rely on the AJAX server handler to return the right number of matches (ie LIMIT on the SQL query).
        });
问题是,当从第二个文本框调用typeahead函数时,typeahead所在的上下文看不到添加的属性。调用typeahead函数时,如何使添加属性的值可用


感谢您的帮助。谢谢

什么是p_field_obj?它是每个filter_typeahead项的对象,即:p_field_obj=$'filter____热点_id'添加的属性是什么?数据过滤器附加id和数据过滤器附加col,根据输入filter_热点_id的数据添加到filter_接口上。guest271314,非常感谢你的帮助。这个问题涉及到相当多的独立代码位,因此很难尝试用一些片段来解释它。我一直在做一些研究,并没有发现任何方法可以使引导模式中的数据更改得到刷新,并可用于typeahead函数。我已经放弃了,并尝试了另一种选择,这似乎是可行的。再次感谢。这是我第一次发布一个问题,但我真的不知道如何结束它。如果其他人可以,请随时关闭它。