Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- function initTaggingControl() {
- RTE.CanvasEvents.registerListener(RTE.CanvasEvents.editableRegionChangedEvent, Function.createDelegate(null, onCustomTextChanged));
- }
- function onCustomTextChanged(sender, args) {
- var ll = $(args.editableRegion).parents().length;
- if (args.editableRegion.innerText.length > 0) {
- for (var j = 0; j < ll; j++) {
- var a = $(args.editableRegion).parents()[j].FieldName;
- if (a === "Responsibility Customer" || a === "Supplier Cost") {
- customernamefun();
- }
- }
- }
- }
- function getCurrentMainCategoryID() {
- var currentMainCatId = 0;
- var respsubcategory = $("select[id*='ResponsibilitySubCategory']");//this is a dro-down
- if (respsubcategory !== null && respsubcategory !== '') {
- // do something
- var currentsubcat = $("select[id*='ResponsibilitySubCategory'] :selected").text();
- alert(currentsubcat);
- //code goes here
- }
- function customernamefun() {
- var customer = $("div[id*='ResponsibilityCustomer_']");
- var customersite = $("select[id*='ResponsibilityCustomerSite_']");
- var currentcustomersite = customersite.val();
- if (customer !== null && customer !== '') {
- // do something
- var currentcustomer = $("div[id*='ResponsibilityCustomer_']").find("span").text();
- alert("cusotmname"+currentcustomer);
- if (currentcustomer == '' || currentcustomer == null) {
- customersite.find('option').remove();
- }
- var results = "";
- var body = {
- 'query': {
- '__metadata': {
- 'type': 'SP.CamlQuery'
- },
- 'ViewXml': "<View><Query><Where><Eq><FieldRef Name='ResponsibilityCustomer'/><Value Type='TaxonomyFieldType'>" + currentcustomer + "</Value></Eq></Where></Query></View>"
- }
- };
- $.ajax({
- url: "/_api/web/lists/getbytitle('Customer%20Site')/GetItems",
- method: "POST",
- contentType: "application/json;odata=verbose",
- async: false,
- data: JSON.stringify(body),
- headers: {
- "Accept": "application/json; odata=verbose",
- "X-RequestDigest": $('#__REQUESTDIGEST').val()
- },
- success: function(data2) {
- if (data2.d.results.length > 0) {
- customersite.find('option').remove();
- results2 = data2.d.results;
- for (var ii = 0; ii < results2.length; ii++) {
- if (results2[ii].Id == currentcustomersite)
- customersite.append(new Option(results2[ii].Title, results2[ii].Id, true, true));
- else
- customersite.append(new Option(results2[ii].Title, results2[ii].Id));
- }
- }
- if (data2.d.results.length <= 0) {
- customersite.find('option').remove();
- }
- },
- error: function(data) {
- alert("Error");
- }
- });
- return results;
- }
- }
- ExecuteOrDelayUntilScriptLoaded(initTaggingControl, 'ScriptForWebTaggingUI.js');
- ExecuteOrDelayUntilScriptLoaded(getCurrentMainCategoryID, "sp.js");
- ExecuteOrDelayUntilScriptLoaded(customernamefun, "sp.js");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement