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() :
1syncUI: function() {
2 var instance = this;
3 AssetTagsSelector.superclass.syncUI.apply(instance, arguments);
4 var curEntries = instance.get('curEntries');
5 A.each(curEntries, instance.add, instance);
6 },
I am getting recently entered text from _onAddEntryClick: function(event) :
1 _onAddEntryClick: function(event) {
2 var instance = this;
3 var text = instance.inputNode.val();
4 alert(text); // Recently entered text
5 if (text) {
6 if(text.indexOf(',') > -1) {
7 var items = text.split(',');
8 A.each(
9 items,
10 function(item, index, collection) {
11 instance.entries.add(item, {});
12 }
13 );
14 } else {
15 instance.entries.add(text, {});
16 }
17 }
18 Liferay.Util.focusFormField(instance.inputNode);
19 },
Now i have edited the above function (_onAddEntryClick: function(event) ) as below:
1_onAddEntryClick: function(event) {
2 var instance = this;
3 var currentEntries = instance.get('curEntries');
4 alert("currentEntries :" +currentEntries ); // getting all the existing entries
5 for(var i=0; i<currentEntries.length; i++){
6 var myentries = currentEntries[i].trim();
7 alert("myentries "+myentries);
8 var text = instance.inputNode.val().trim();
9 alert("text :" +textt); // getting most recently added text
10
11 if( myentries == text ) // comparing recently added text with existing entries
12 {
13 alert( "Tag already exists");
14 }
15 } // end of for loop
16
17 if (text ) {
18 if(text.indexOf(',') > -1) {
19 var items = text.split(',');
20
21 A.each(
22 items,
23 function(item, index, collection) {
24 instance.entries.add(item, {});
25 }
26 );
27 } else {
28 instance.entries.add(myentries, {});
29 }
30 }
31 Liferay.Util.focusFormField(instance.inputNode);
32 },
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
Be kell jelentkezni ahhoz, hogy ez helytelenként legyen megjelölve.