Permalink
Browse files

Field name for tags can now be set via the "field_name" option

  • Loading branch information...
1 parent b3956ad commit 9b881068db520cb02988841ca7795f81efdd0b21 @rfletcher committed Apr 7, 2009
Showing with 7 additions and 8 deletions.
  1. +1 −1 src/lib/Tagbox.Tag.js
  2. +6 −7 src/lib/Tagbox.js
View
@@ -36,7 +36,7 @@ Tagbox.Tag = Class.create( {
initialize: function( tagbox, properties ) {
this.tagbox = tagbox;
this.properties = new Hash( this.properties );
- this.properties.set( 'field_name', tagbox.name );
+ this.properties.set( 'field_name', tagbox.options.get( 'field_name' ) );
if( typeof properties == "string" ) {
properties = { value: properties };
View
@@ -36,6 +36,8 @@ var Tagbox = Class.create( {
* and/or permitted tags.
* delimiters (Array) = [ Event.KEY_COMMA, Event.KEY_RETURN ]:
* Array of keyCodes which trigger addition to the list of tags.
+ * field_name (String) = name of the original text input
+ * The form field name, taken from the original input element.
* hint (String) = null:
* A brief instruction to the user.
* hint_delay (Number) = 100:
@@ -64,6 +66,7 @@ var Tagbox = Class.create( {
delimiters: [ Event.KEY_COMMA, Event.KEY_RETURN ],
hint: null,
hint_delay: 100,
+ field_name: null,
max_tags: null,
result_converter: null,
show_remove_links: true,
@@ -89,12 +92,6 @@ var Tagbox = Class.create( {
hint_timeout: null,
/**
- * Tagbox#name -> String
- * The form field name, taken from the original input element.
- **/
- name: null,
-
- /**
* Tagbox#element -> Element
* The tagbox (<div/>) element.
**/
@@ -116,7 +113,9 @@ var Tagbox = Class.create( {
this.options = new Hash( this.options ).update( options );
this.tags = [];
- this.name = $( original_input ).getAttribute( 'name' );
+ if( ! this.options.get( 'field_name' ) ) {
+ this.options.set( 'field_name', $( original_input ).getAttribute( 'name' ) );
+ }
this.initializeAllowedTags();
this.insert( original_input );

0 comments on commit 9b88106

Please sign in to comment.