TextEntryButton

Iaac Lauzy8 May 2011 7:51 PM
CODE
var RegistrationView = new KONtx.Class({

ClassName: 'RegistrationView',



Extends: KONtx.system.SidebarView,





createView: function() {
var password;

this.controls.backButton = new KONtx.control.BackButton({

label: "Back",

guid: "back_button",

styles: {

width: this.width

}

}).appendTo(this);




})

this.controls.usernameButton = new KONtx.control.TextEntryButton({

guid: 'Username',

label: 'Username',

styles: {

vOffset: this.controls.backButton.outerHeight



}

}).appendTo(this);

this.controls.passwordButton = new KONtx.control.TextEntryButton({

guid: 'Password',

label: 'Password',

secureMask: true,

secureMaskType: 'mask-all',

styles: {

vOffset: this.controls.usernameButton.outerHeight



},
events: {
onSubmit: function(event) {
log($dump(event));
log($dump(event.payload));
log(event.payload.value);
this.password = event.payload.value;
var dialog = new KONtx.dialogs.Alert({
title: "Dialog Title",
message: this.password,
buttons: [{
label: "Ok",
callback: function(){

}
}],
cancelCallback: function() {
log("Dialog was canceled by the user by hitting the back button");
}
});
dialog.show();

}
}

}).appendTo(this);

this.controls.confirmPasswordButton = new KONtx.control.TextEntryButton({

guid: 'confirmPass',

label: 'Confirm Password',

secureMask: true,

secureMaskType: 'mask-all',
data: 'test',

styles: {

vOffset: this.controls.passwordButton.outerHeight



}

}).appendTo(this);




this.controls.submitButton = new KONtx.control.TextButton({

label: 'Register',



styles: {

width: 294,

height: 25,

textAlign: "left",

vOffset: this.controls.nameButton.outerHeight

}, //Style information for the Button stored in our 960x540.js file

events: {


//Setup a onSelect Event to handle the button action

onSelect:function(event){
//var password = this.getView().controls.passwordButton.value;
var cPassword = this.getView().controls.confirmPasswordButton.value;


var dialog = new KONtx.dialogs.Alert({
title: "Dialog Title",
message: this.password,
buttons: [{
label: "Ok",
callback: function(){
log("User said everything is a-ok!");
}
}],
cancelCallback: function() {
log("Dialog was canceled by the user by hitting the back button");
}
});
dialog.show();





}

}).appendTo(this);







},







updateView: function() {


},





});


I am now trying to set the text entered in the password text entry button into a variable 'password' . The dialog box in the text entry button actually shows the value of the password variable however, the dialog box in the submit button shows the value of the password variable as 'undefined'. Can anyone tells me why did it happen?
Benjamin Toll17 May 2011 1:56 PM
Do this:

CODE
var password = this.getView().controls.confirmPasswordButton.getValue();

var dialog = new KONtx.dialogs.Alert({
title: "Dialog Title",
message: password,
buttons: [{
label: "Ok",
callback: function(){
log("User said everything is a-ok!");
}
}],
cancelCallback: function() {
log("Dialog was canceled by the user by hitting the back but
ton");
}
});

By the way, your code is riddled with typos and bad syntax. I had to alter it in several places just to get it to load.
ABHISHEK9 Jan 2012 12:55 AM
I am a beginner .. want to know how to fetch value using getValue()&nbsp; from the textEntryButtons . i am&nbsp; creating &nbsp;a simple login form&nbsp; and want to test if both userid and password is &quot;admin&quot;&nbsp;. but how do i compare the values entered in userid and password textEntry button ......&nbsp; <br><br>thanks in advance <br><br><font></font> &nbsp;
Vivek Jani9 Jan 2012 9:13 AM
Not fully sure what you mean. You can use control.getValue() to get the value of that control and use simple javascript comparison using == to do this(although for passwords this is unsecure)<br><br>[code]<br>&nbsp;&nbsp;&nbsp;&nbsp;if(this.controls.userId.getValue() == &quot;admin&quot; &amp;&amp; this.controls.password.getValue() == &quot;admin&quot;)<br> log(&quot;user is admin&quot;)<br>[/code]<br><br>Thanks,<br>Vivek<br><br> QUOTE (ABHISHEK @ 9 Jan 2012 12:55 AM) I am a beginner .. want to know how to fetch value using getValue()&nbsp; from the textEntryButtons . i am&nbsp; creating &nbsp;a simple login form&nbsp; and want to test if both userid and password is &quot;admin&quot;&nbsp;. but how do i compare the values entered in userid and password textEntry button ......&nbsp; <br><br>thanks in advance <br><br><font></font> &nbsp;