Note that there are some explanatory texts on larger screens.

plurals
  1. POTitanium cloud.users.show
    primarykey
    data
    text
    <p>In my titanium app.js, i have the cloud register/login code snippets below...</p> <p>register: </p> <pre><code>var btnR = Titanium.UI.createButton({ title: 'register', top: 350, left: 10, width: 100, height:28 }); btnR.addEventListener('click', function(){ Cloud.Users.create ({ username: username.value, password: password.value, password_confirmation : passwordConfirmation.value, firstName: firstName.value, lastName: lastName.value, email : email.value }, function (e) { if (e.success) { var user = e.users[0]; Ti.App.fireEvent('register'); } else { alert('fail :' + e.message); } }); }); </code></pre> <p>login:</p> <pre><code>var btnL = Titanium.UI.createButton({ title: 'log in', top: 190, left: 10, width: 100, height:50 }); btnL.addEventListener('click', function(){ Cloud.Users.login({ login: userNameField.value, password: passwordField.value, }, function (e) { if (e.success) { var user = e.users[0]; Ti.App.fireEvent('login'); } else { alert('fail:' + e.message); } }); }); </code></pre> <p>And in my home.js, i have the following code.</p> <pre><code>var search = Titanium.UI.createSearchBar({ hintText: 'search here', showCancel:true, height:35, top:10, center:0, width:250 }); view6.add(search); search.addEventListener('cancel', function(e) { Titanium.API.info('search bar cancel fired'); search.blur(); }); </code></pre> <p>Okay, my question is, if i want a user to be able to search for other users through the search bar, how am i going to do it. I tried the code below but it gives me an error.."can't find variable userId at home.js". Thanks as you help me.</p> <pre><code>search.addEventListener('return', function(e) { Cloud.Users.show({ user_id: userId }, function (e) { if (e.success) { var user = e.users[0]; alert('Success:\n' + 'id: ' + user.id + '\n' + 'first name: ' + user.first_name + '\n' + 'last name: ' + user.last_name); } else { alert('Oops:' + e.message); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload