-
3 May 2012 2:16 PM #1
Numberfield Prompt
Numberfield Prompt
Hey guys,
I needed a prompt for a numberfield instead of text so I extended Ext.MessageBox, here it is if you need it!
Usage:Code:Ext.define( 'App.NumberPrompt' , { extend: "Ext.MessageBox" , requires: [ 'Ext.field.Number' ], xtype: "numberPrompt" , applyPrompt: function(prompt) { if (prompt) { var config = { label: false }; if (Ext.isObject(prompt)) { Ext.apply(config, prompt); } return Ext.factory(config, Ext.field.Number, this.getPrompt()); } return prompt; } });
Code:var myNumberPrompt = Ext.create( 'App.NumberPrompt' ); myNumberPrompt.prompt( 'Number' , 'Please enter a number:' , function( number ) { // process number value and close... });
-
5 May 2012 5:39 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Your code produces a number field. One thing I would do is applyPrompt as two arguments, the new prompt and the current prompt
Code:applyPrompt : function (prompt, oldPrompt) { if (prompt) { var config = { label : false }; if (Ext.isObject(prompt)) { Ext.apply(config, prompt); } return Ext.factory(config, Ext.field.Number, oldPrompt); } return prompt; }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Jul 2012 1:51 AM #3
Incorrect parameter !
Incorrect parameter !
When you use this number prompt, the number entered is THE SECOND paramater of the function
In fact, the first paramater always return button status ('ok' or 'cancel')
Code:myNumberPrompt.prompt( "Prompt", 'Enter a number :' , function( a,number ) { console.log(number); });


Reply With Quote