How can I improve my jQuery form preview implementation? I'm currently using the jQuery Instagram Plugin to get the hashtag from Instagram.
var timeoutReference;
var element;
var tagsa;
$(document).ready(function() {
$('input#instagram_hashtag_hashtag').keypress(function() {
if (timeoutReference) clearTimeout(timeoutReference);
timeoutReference = setTimeout(function() {
doneTyping($('input#instagram_hashtag_hashtag').val());
}, 350);
});
$('input#instagram_hashtag_hashtag').blur(function(){
doneTyping($('input#instagram_hashtag_hashtag').val());
});
});
function doneTyping(tags){
if (!timeoutReference){
return;
}
tagsa = null;
tagsa = tags.match(/(^#|\s#)([a-z0-9]+)/gi);
timeoutReference = null;
var length = tagsa.length,
element = null;
for (var i = 0; i < length; i++) {
element = tagsa[i];
$(function(){
var
insta_container = $(".instagram")
, insta_next_url
insta_container.instagram({
hash: element.replace("#", "")
, clientId: 'instagramclientid'
, show : 4
})
});
}
}