Jquery Mobile listview搜索

时间:2016-05-12 11:29:40

标签: javascript jquery jquery-mobile jquery-mobile-listview jquery-mobile-dialog

我正在创建一个项目,用户输入名称并在框中弹出名称,但您可以单击以在对话框中获取更多信息。我的代码正在运行,但是对于正确显示完整信息的对话框,您需要在搜索字段中键入至少4个字符。我希望用户能够获得额外的信息,即使他们输入少于4个字符。见下文:))

search screen

dialog screen

以下是我的剧本,我希望这对某人有意义。 :)

$(document).ready(function() {

    $('#search').click(function() {
        $(".artist").remove();  // removes the artist class to clear search
        var artists = "js/data.json"; // places the file link into variable

        $.getJSON( artists, function(data) { //  uses the variable to connect to json file
            console.log(data);  
            $.each( data, function( i, item ) { // loops through the json files to retrieve required info
            // section for artists brief intro 
            $("ul#artist").append( "<li class='artist'><span style='font-size:24px; font-weight:bold;color:red;'>"  + item.name  + 
                "</span><br/>" + item.reknown + 
                "<br/><button class='ui-btn' id='information'><a href='#dialog' data-role='button' id='dialog' data-transition='flip'>More Information</a></button></li>");
            }); // end of each function

            $('#search').first().one('keyup', function(){   
             $.each( data, function( i, item ) {    // loops through the json files to retrieve required info
            // section for artists dialog full profile data
            $("ul#artist2").append( "<li class='artist'><span style='font-size:24px; font-weight:bold;color:red;'>" + item.name + 
                "</span><br/> " + item.reknown + 
                "<br/><img class='profile' src='images/" + item.shortname + "_tn.jpg' />" + 
                "<br/><span style='font-size:18px; color:red; font-weight:bold'>Bio:</span><br> " + item.bio + "</li>"); 

                });  // end of information function
             }); // end of each function  
        }); // end of getJson function 
    });  // end of submit on click function

});  // end document ready function 

0 个答案:

没有答案