I am creating a project whereby the user enter a name and the name pops up in the box but you can click to get more information in a dialog box. My code is working but for the dialog to show the full information correctly you need to type at least 4 characters in the search field. I would like user to be able to get additional information even if they enter less than 4 characters. See below :)
Below is my script, I hope this makes sense to someone. :)
$(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