官术网_书友最值得收藏!

  • Sencha Touch Cookbook
  • Ajit Kumar
  • 345字
  • 2021-08-20 15:56:07

Introduction

Most of the useful applications not only present the data, but also accept inputs from their users. When we think of having a way to accept inputs from the user, send them to the server for further processing, and allow the user to modify them, we think of forms and the form fields. If our application requires users to enter some information, then we go about using the HTML form fields, such as <input> , <select> , and so on, and wrap inside a <form> element. Sencha Touch uses these tags and provides convenient JavaScript classes to work with the form and its fields. It provides field classes such as Url , Toggle , Select , Text , and so on. Each of these classes provides properties to initialize the field, handle the events, and utility methods to manipulate the behavior and the values of the field. On the other side, the form takes care of the rendering of the fields and also handles the data submission.

Each field can be created by using the JSON notation (JavaScript Object Notationhttp://www.json.org) or by creating an instance of the class. For example, a text field can either be constructed by using the following JSON notation:

{
  xtype: 'textfield',
  name: 'text',
  label: 'My Text'
}

Alternatively, we can use the following class constructor:

var txtField = new Ext.form.Text({
  name: 'text',
  label: 'My Text'
});

The first approach relies on xtype, which is a type assigned to each of the Sencha Touch components. It is used as shorthand for the class. The basic difference between the two is that the xtype approach is more for the lazy initialization and rendering. The object is created only when it is required. In any application, we would use a combination of these two approaches.

In this chapter, we will go through all the form fields and understand how to make use of them and learn about their specific behaviors. In addition, we will see how to create a form using one or more form fields and handle the form validation and submission.

主站蜘蛛池模板: 成都市| 门头沟区| 内黄县| 青岛市| 肇源县| 天峻县| 梁平县| 安新县| 灵宝市| 中西区| 雷州市| 多伦县| 常山县| 白玉县| 碌曲县| 砀山县| 志丹县| 贡山| 盱眙县| 龙山县| 泸溪县| 天全县| 大安市| 额尔古纳市| 兴国县| 胶南市| 榆树市| 长武县| 黄平县| 彭山县| 阳西县| 云和县| 文安县| 西和县| 阳东县| 平原县| 凌源市| 大荔县| 昌邑市| 米脂县| 宁津县|