Fórumok

Alloy TextBoxList - customization

thumbnail
dave ch, módosítva 11 év-val korábban

Alloy TextBoxList - customization

Regular Member Bejegyzések: 161 Csatlakozás dátuma: 2012.02.07. Legújabb bejegyzések
Hi all,

I want to customize asset_tags_selector.js.( html/js/liferay/asset_tags_selector.js.).
Inside control panel--> web content--> categorization -->tags , while adding a tag which already exist inside TextBoxList i want to generate an alert message, "Tag already Exist".
From asset_tags_selector.js , I am getting current entries from syncUI: function() :
syncUI: function() {
						var instance = this;
						AssetTagsSelector.superclass.syncUI.apply(instance, arguments);
						var curEntries = instance.get('curEntries');
                        			A.each(curEntries, instance.add, instance);
					},


I am getting recently entered text from _onAddEntryClick: function(event) :

	_onAddEntryClick: function(event) {
						var instance = this;
						var text = instance.inputNode.val();
                                                 alert(text); // Recently entered text
						if (text) {
							if(text.indexOf(',') > -1) {
								var items = text.split(',');
								A.each(
									items,
									function(item, index, collection) {
										instance.entries.add(item, {});
									}
								);
							} else {
								instance.entries.add(text, {});
							}
						}
						Liferay.Util.focusFormField(instance.inputNode);
					},


Now i have edited the above function (_onAddEntryClick: function(event) ) as below:
_onAddEntryClick: function(event) {
						var instance = this;
                 			var currentEntries = instance.get('curEntries');
                             alert("currentEntries  :" +currentEntries );        // getting all the existing entries
                        for(var i=0; i<currententries.length; i++){ var myentries="=" alert("myentries "+myentries); text alert("text :" +textt); getting most recently added if( ) comparing with existing entries { alert( "tag already exists"); } end of for loop if (text if(text.indexof(',')> -1) {
								var items = text.split(',');
                                     
								A.each(
									items,
									function(item, index, collection) {
										instance.entries.add(item, {});
									}
								);
							} else {
								instance.entries.add(myentries, {});
								}
						}
						Liferay.Util.focusFormField(instance.inputNode);
					},</currententries.length;>


In the above code, myentries and text (myentries == text) are never same, the alert message should appear when they are equal, but they are always different, means when i am trying with
if( myentries != text ){
alert(" not equal") }, this is working.
The type when i am trying to get using "typeof" of the two variables(myentries and text) they are always "String", then for what reason they are always unequal.????
I tried it many different ways but i didn'd success-ed.
Can any body please tell me why i am getting this issue?
Any input will be appreciated ..!

Regards,

Dave
thumbnail
dave ch, módosítva 11 év-val korábban

RE: Alloy TextBoxList - customization

Regular Member Bejegyzések: 161 Csatlakozás dátuma: 2012.02.07. Legújabb bejegyzések
I solved this using toLowercase(),

if(myEntry.toLowerCase() == text.toLowerCase())
{
}
thumbnail
dave ch, módosítva 11 év-val korábban

RE: Alloy TextBoxList - customization

Regular Member Bejegyzések: 161 Csatlakozás dátuma: 2012.02.07. Legújabb bejegyzések
But now another issue i my facing.
Let us suppose we have 2 tags inside the TextBoxList which were currently Published are: department and rules.
Now i am adding a new tag as: Rules, here R is in capital letter. Here it works, it shows the alert message i have kept.
But when i am trying to add the same text like suppose: rules(in small letters), i am not getting any message and it mixes with the existing text from TextBoxList.

My question is from where this is getting this TEXT Mixing functionality.

Any input would be appreciated.

Regards,

Dave