Backend Category Selector
Hello-
I'm working on functionality to get the list of currently selected categories for a content item (blogs in my case). I have written a custom field that has a drop down list but I want to populate it on the fly with the current selected categories. The goal being to mark one category logically as the "primary" category for this item.
Here is what I've tried so far:
1) I've tried calling the Telerik.Sitefinity.Web.UI.Fields.HierarchicalTaxonField javascript object in various ways to eitehr add a new event to the selection done delegate, or to get the list of selected taxa with no luck.
2) I've tried using jQuery to get a list of all of the sub-items in the sfCategoriesList class, but jQuery for some reason cannot see these elements, even though I can inspect them through the DOM.
I have been able to use the jQuery live syntax to bind an event to the category done button like this:
jQuery(
".sfLinkBtnIn:contains('Done')"
).live(
'click'
,
function
()
// custom logic here
console.log(jQuery(
".sfCategoriesList"
).size());
// always returns 0
);
Hi Thomas Weidman,
HierarchicalTaxonField provides two functions:
add_taxonAdded - This function allows other objects to subscribe to the taxonAdded event of the taxon field.
add_taxonRemoved - This function allows other objects to subscribe to the taxonRemoved event of the taxon field.
So, if you have access to HierarchicalTaxonField object, you could use the functions above to subscribe for taxonAdded and taxonRemoved events and add/remove items to/from your drop down on fly. For example:
field.add_taxonAdded(addTaxon);
function
addTaxon(sender, args)
//custom code
Pepi-
Hello.Thank you for the reply you've got me looking in the correct direction now. One question, how to I invoke the add_taxonAdded method? The field I'm building is using the "ChoiceField" format so I can have it display as a select list. I used firebug and tried looking at the following objects:
Telerik.Sitefinity.Web.UI.Fields.TaxonField
Telerik.Sitefinity.Web.UI.Fields.HierarchicalTaxonField
Both return an undefined, so I'm missing something to allow this code to access the function to subscribe to the events you mentioned.
Thanks,
-Thomas
Pepi-
Thanks for your reply, I figured it out.
-Thomas
Hi Thomas,
Could you please share the solution with others who may follow the forum post?
Thank you!
Kind regards,
Veronica Milcheva
the Telerik team