(function ($) { // Utilities $.fn.AuditHistoryUtils = (function () { var auditutils = {}; auditutils.bindinputfields = function (container, datefieldval) { // 11/2019: Audit History Events var $container = $(container); var date = datefieldval; // reference all the audit history container classes and build qtips for each var $auditcontainerfields = $container.find(".input-container-position"); $.each($auditcontainerfields, function (i, e) { // reference the input field var $auditelement = $(this); var $inputfield = $auditelement.find("input"); $auditelement.append(""); var $auditfield = $auditelement.find("a.input-audit-history"); // BIND THE QTIP POPUP TO THE RENDERED AUDIT HISTORY ELEMENT $auditfield.qtip( { content: { title: { text: "Input History", button: true }, text: function (eventtip, api) { var $auditcontainer = $(this).closest(".input-container-position"); var area = $auditcontainer.data("area"); var controller = $auditcontainer.data("controller"); var tag = $auditcontainer.data("tag"); api.elements.content.html('

Loading

'); //api.set('content.text', ); return $.ajax({ method: "POST", url: "/AuditHistory/InputHistory/InputDataHistory", data: { areaname: area, controllername: controller, inputtag: tag, effectivedate: date } }) .then(function (content) { // Return the content instead of using .set(). If you're wanting to select // specific elements, see ther above section and adapt the `api.set` call // into a `return elements` statement! return content; }, function (xhr, status, error) { // Errors aren't handled by the library automatically, so // you'll need to call .set() upon failure, just as before. api.set('content.text', status + ': ' + error); }); } }, style: { classes: 'qtip-mcccore' }, show: { solo: true, event: 'click' }, hide: { event: 'unfocus' }, position: { my: 'center', at: 'center', target: 'mouse', // Track the mouse as the positioning target container: $("#env-private"), viewport: $(window), adjust: { // Don't adjust continuously the mouse, just use initial position mouse: false } } }); // BIND THE AUTO SAVE FEATURE FOR THIS AUDIT HISTORY INPUT FIELD $auditfield.attr("data-inputdata", $inputfield.val()); $inputfield.donetyping(function () { // send value to audit save var $thisinputfield = $(this); var $thisauditfield = $thisinputfield.siblings("a").not(this).eq(0); var $thisauditcontainer = $(this).closest(".input-container-position"); var area = $thisauditcontainer.data("area"); var controller = $thisauditcontainer.data("controller"); var tag = $thisauditcontainer.data("tag"); var data = $thisauditfield.attr("data-inputdata"); var newdata = $thisinputfield.val(); $thisauditfield.attr("data-inputdata", newdata); $.post("/AuditHistory/InputHistory/SaveDataForAudit", { areaname: area, controllername: controller, inputtag: tag, effectivedate: date, prevvalue: data, currentvalue: newdata }); }); }); }; return auditutils; })(); })(jQuery);