Managed Metadata
Posted by stieland - Feb 25 ’14 at 02:49
I am trying to work with Managed Metadata fields and have not been able to pick up the change event for a Managed Metadata field.
fd.field('RCategory').change(function() {
alert('Category Changed');
});
Never fires the alert. Do Managed Metadata fields work differently?
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
Please, try to use the following code to handle changing of Management Metadata field:
var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0); container.JavascriptOnValidation = "alert('Managed metadata changed!')";
-
stielandMemberMember for: 9 years 11 months 14 days
While that is firing when the item is updated, also a few more times. I am still missing a few items to get my piece working.
I need to know when the managed metadata field equals 'Option 2' and if it equals 'Option 2', then I need to make another control visible. If it does not equal 'Options 2' then the other control is hidden.
I do not seem to be able to get the value of the managed metadata field so that I can compare it.
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
[#2]: You can find examples of getting and setting Taxonomy field values in the following article:
http://blog.vgrem.com/tag/taxonomywebtaggingcontrol/
Getting:
var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0); var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(container); var termValue = taxCtlObj.getRawText();
-
Christian HeinrichMemberMember for: 8 years 3 months 26 days
[#1]: Should that alternat event registration also work for SP 2010?
I did put that code into the JavaScript part of the form, but the alert never shows up...
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
[#4]: Please, try the following code for SP2010:
var container = fd.field('TermStore1').control()._el().find('div.ms-taxonomy').get(0); container.JavascriptOnValidation = "alert('Managed metadata changed!')";
-
SophiaSmith2395MemberMember for: 8 years 3 months 22 days
The message was removed by a forum moderator.
-
DanMemberMember for: 8 years 30 days
[#1]: It seems like the only thing you can do in here is report out that it's fired. Trying to call an handler function doesn't seem to work properly. I've tried a couple things and some variations of them:
container.JavascriptOnValidation = "mmChangeHandler()";
function mmChangeHandler() {
console.log("Managed Metadata Changed!");
}
/* OR */
container.JavascriptOnValidation = function() {
console.log("Managed Metadata Changed!");
}
-
rostislavModeratorMember for: 8 years 22 days
[#7]:
You can define a global function and then call it:
container.JavascriptOnValidation = "func()"; window.func = function () { console.log("Managed Metadata Changed!"); }
-
DanMemberMember for: 8 years 30 days
[#8]:
That worked! Thanks!
-
KatyMemberMember for: 8 years 10 months 10 days
Hi!
I checked with alert and it works fine indeed. I need to insert the check for mandatory field with metadata. I tried some options like:
fd.field('FieldName').control()._el().find('.ms-taxonomy').value()
fd.field('FieldName').control()._el().find('.ms-taxonomy').value() == ""
fd.field('FieldName').control()._el().find('.ms-taxonomy').length > 0
but nothing works :-( Howcan I use it in IF statement to check if the metadata field contains any information?