Managed Metadata
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?
fd.field('RCategory').change(function() {
alert('Category Changed');
});
Never fires the alert. Do Managed Metadata fields work differently?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Please, try to use the following code to handle changing of Management Metadata field:
Code: Select all
var container = fd.field('InternalName').control()._el().find('.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')";
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.
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 Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
You can find examples of getting and setting Taxonomy field values in the following article:
http://blog.vgrem.com/tag/taxonomywebtaggingcontrol/
Getting:
http://blog.vgrem.com/tag/taxonomywebtaggingcontrol/
Getting:
Code: Select all
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 Heinrich
- Posts: 5
- Joined: Tue Feb 03, 2015
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...
I did put that code into the JavaScript part of the form, but the alert never shows up...
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Please, try the following code for SP2010:
Code: Select all
var container = fd.field('TermStore1').control()._el().find('div.ms-taxonomy').get(0);
container.JavascriptOnValidation = "alert('Managed metadata changed!')";
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!");
}
container.JavascriptOnValidation = "mmChangeHandler()";
function mmChangeHandler() {
console.log("Managed Metadata Changed!");
}
/* OR */
container.JavascriptOnValidation = function() {
console.log("Managed Metadata Changed!");
}
You can define a global function and then call it:
container.JavascriptOnValidation = "func()";
container.JavascriptOnValidation = "func()";
Code: Select all
window.func = function () {
console.log("Managed Metadata Changed!");
}
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?
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

-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests