SuiteCRM - JQuery Masked Input Plugin Not Working

I checked several other threads related to masked input plugins that are not working and could not find answers:

Masked input plugin not working

jQuery Masked Input plugin not working on form input?

JQuery Masked input plugin not working

I must summarize this by saying that my programming knowledge is rather limited. I have help, but this help is not always available.

I am trying to use this plugin

My Version #: SuiteCRM Version 7.2.1, Sugar Version 6.5.20 (Build 1001)

So, I added jQuery javascript library file and jQuery plugin from digitalbrushes site and placed them as in / admin / custom / include / javascript /

Then under the module I'm currently working in, which in this case is the Contracts module, the file I'm working on is located here: / admin / custom / modules / AOS _Contracts / views / view.edit.php

Below is the file:

<?php 
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 

require_once('include/MVC/View/views/view.edit.php'); 

class AOS_ContractsViewEdit extends ViewEdit {

// function displaySubPanels() {
//  return '';
// }

function display(){
    $js = <<<JS

            <script src="/admin/custom/include/javascript/jquery.min.js" type="text/javascript">
            <script src="/admin/custom/include/javascript/jquery.maskedinput.min.js" type="text/javascript">
            var \$j = jQuery.noConflict();
                \$j("#home_phone_c").mask("(999) 999-9999");
                \$j("#work_phone_c").mask("(999) 999-9999");
                \$j("#mobile_phone_c").mask("(999) 999-9999");
                \$j("#inital_deposit_amount_c").mask("999,999,999,999,999.99");
                });
            </script>
    JS;
        parent::display();
        echo $js;

    }

}

      

When I load the page and click in the fields, there are no masks in my chrome console, I get an unrelated error in my style.js file that reads:

"Uncaught TypeError: $ .cookie is not a function"

I've already tried wrapping this in {literal} tags as suggested in this answer: Adding custom jQuery validation to SugarCRM editview , nothing changed. I'm not sure how or if this function () (function ()) applies to it, I didn't think it was because of parent::display();

.

I've tried this same page on Chrome, Firefox, Safari and IE ... nothing. I also cleared my cache and cookies after I made changes to make sure I get fresh results. I have also done a quick repair and refurbishment on SuiteCRM every time (although it should be completely optional) to cover my bases.

+3


source to share


2 answers


I was able to get help on the SuiteCRM forum.

- I need this cookie plugin

- In my syntax, the above src="jquery.maskedinput.min.js"

should have been omitted.



- In my syntax above \$j

was creating an endless error in chrome console which only appeared after removing the above syntax, I omitted j

and then cleaned it up!

The corrected code looks like this:

<?php 
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 

require_once('include/MVC/View/views/view.edit.php'); 

class AOS_ContractsViewEdit extends ViewEdit {

    // function displaySubPanels() {
    //  return '';
    // }

    function display(){
        $js = <<<JS

                <script src="custom/include/javascript/js.cookie.js" type="text/javascript"></script>
                <script type="text/javascript">
                var \$ = jQuery.noConflict();
                    \$("#home_phone_c").mask("(999) 999-9999");
                    \$("#work_number_c").mask("(999) 999-9999");
                    \$("#mobile_number_c").mask("(999) 999-9999");
                    \$("#inital_deposit_amount_c").mask("");
                </script>
JS;
        parent::display();
        echo $js;

    }

}
?>

      

+3


source


You need to add the JS file to the metadata using "include". Then write your code in this file. Writing java-script code inside a PHP view is not suggested by Sugar.



If you only need view.edit for this purpose, then at the end this file will not be needed and therefore will be removed. Let me know if you need more information.

0


source







All Articles