How to call functionality from the autoload.js file in the logic.js file of a widget
Content
Hi,
From the code block below, you can see I have quite a length function called validateForm. This sits across several widgets. If I have to make a change, I have to do it in several places. If it's in 100 widgets.... 100 changes
My question is whether I can utilise the autoload.js file to contain this function and call it from logic.js? How would I go about ding this if so?
Code Snippet
RightNow.namespace('Custom.Widgets.planning_programming.Submit'); Custom.Widgets.planning_programming.Submit = RightNow.Widgets.FormSubmit.extend({ overrides: { constructor: function(){ this.parent(); RightNow.Event.subscribe("on_before_ajax_request", this._onBeforeAjaxRequest1, this); var form = RightNow.Form.find('rn_QuestionSubmit', this.instanceID); form.on("submit", this.onValidate, this); } , validateForm: function(type, args){ var elem = document.getElementById('rn_QuestionSubmit').elements; var a = []; var result = {}; for(var i = 0; i < elem.length; i++) { var element = elem[i]; var item = {}; if (element.name === '' || element.name.indexOf(".") >= 0) { continue;} if (element.type === 'select-one') { item.text = element.options[element.selectedIndex].text; } item.group = element.dataset.group; item.name = element.name; if (element.type === 'radio' || element.type === 'checkbox') { if (element.checked) { item.value = element.value; if (result[element.name]) { var lastEntry = result[element.name].slice(-1)[0]; if (lastEntry.group === item.group) { lastEntry.value += "," + element.value; } else { result[element.name].push(item); } }
0