I was recently trying my best to create a Kik app that dynamically loaded some content -- messages -- into a textbox when the app launched. document.onload wasn't doing it for me. I tried JQuery's $(document).ready and $(window).load to no avail.
Simple code snippets like this were failing, and I couldn't understand why. They would refuse to function until I attempted to interact with another UI element, resized the screen by rotating my phone, etc...
$(document).ready(function() {
kik.getUser(function(user) {
$('#myDiv').html(user.username);
});
}
This was pretty infuriating... why could I not get Kik to do both in-getUser functions and regular onLoad ones?
Don't ask me why, but this works. I'm just going to assume that you CANNOT wrap kik.getUser
in a $(document).ready
statement!
But who cares -- if kik.getUser
works, then you already have access to the DOM. Cheers!
// Kik user-specific JS
if(kik.utils.platform.browser.kik) {
kik.getUser(function (user) { if ( user ) {
$('#message').html("I work now.");
}});
});
// Kik-agnostic JS
$(document).ready(function() {
$('#version').html("I work now too.");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.