You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 27, 2024. It is now read-only.
**NOTE** that this module has a dependency [Rocket Tools (21kb)](https://github.com/chrishumboldt/Rocket-Tools) which will automatically be installed as well.
25
+
**NOTE** that this module has a dependency [Rocket Tools (28kb)](https://github.com/chrishumboldt/Rocket-Tools) which will automatically be installed as well.
20
26
21
27
Start by including the necessary files.
22
28
@@ -25,7 +31,7 @@ Start by including the necessary files.
@@ -35,52 +41,38 @@ Start by including the necessary files.
35
41
You will need to wrap your form elements with an identifier of your choice. Below is an example of executing the module complete with required HTML and Javascript.
Each initialization will return an array of module objects (An array will always be returned even if the target is an id). This includes the form element itself as well as relevant methods. For example:
53
-
54
-
```javascript
55
-
var forms =Rocket.form();
56
-
57
-
// The form elements and all methods
58
-
for (var i =0, len =forms.length; i < len; i++) {
59
-
console.log(forms[i].form);
60
-
forms[i].clear(); // Clear the value. Works on text inputs and textareas.
61
-
forms[i].toggle('on'); // Toggle the form element to "on". Works on radio and checkboxes.
62
-
forms[i].toggle('off');
63
-
}
64
-
```
65
-
66
-
Alternatively if you know the target is unique you can reference the form element right away with the 0 index. For example:
67
-
68
-
```javascript
69
-
var form =Rocket.form({
70
-
target:'#form-element'
71
-
})[0]; // Reference the first item in the array right away.
72
-
```
55
+
Each initialization will bind to new form targets but will overlook existing ones. However existing form targets will have the state updated.
73
56
74
57
#### Options
75
58
See the different options you have available on initialization.
76
59
77
60
Name | Default | Options | Description
78
61
---- | ---- | ---- | ----
79
-
`target` | `.form` | | Set the HTML target.
62
+
`targets` | `.mod-form` | | Set the HTML target.
80
63
`colour` | `blue` | `grey``black``white``aqua``blue``green``orange``pink``purple``red``grey-blue` | Set the colour of the form elements.
81
64
`label` | `normal` | `normal``shift` | Set an animation on the form label.
82
65
`style` | `line` | `flat``line``raised` | Set the style of the form elements.
83
66
67
+
```javascript
68
+
Rocket.form({
69
+
targets:'.form-element',
70
+
colour:'red',
71
+
label:'shift',
72
+
style:'raised'
73
+
});
74
+
```
75
+
84
76
#### Defaults
85
77
You can also overwrite the module options globally by altering the Rocket defaults. To do so reference the defaults object property, for example:
In this example the only difference to basic inputs is the oder of the elements and the type. Although it is not 100% necessary to change the order, it is good practice.
0 commit comments