简体   繁体   中英

vTiger and jQuery phone mask

I have a phone mask that works but when I add the jQuery to vTiger header, the contact page doesn't paint.

In Header.tpl I have the js reference:

<script type="text/javascript" src="include/jquery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="include/jquery/jquery.maskedinput.min.js"></script>

When I put the needed code in the header.tpl file, the page with the targeted phone field freezes.

<script type="text/javascript">
jQuery(function($){
   $("#phone").mask( "999-999-9999", { placeholder : "_" } );
   });
</script>

Any ideas as to why the page won't paint is appreciated.

You should override getHeaderScripts method in Edit.php file in your module to add your library, add Mask Plugin in Contacts module, better to not modify original template files, only override:

class Contacts_Edit_View extends Vtiger_Edit_View {
    function getHeaderScripts(Vtiger_Request $request) {
            $headerScriptInstances = parent::getHeaderScripts($request);

            $jsFileNames = array(
                'modules.Contacts.resources.Mask'
            );

            $jsScriptInstances = $this->checkAndConvertJsScripts($jsFileNames);
            $headerScriptInstances = array_merge($headerScriptInstances, $jsScriptInstances);
            return $headerScriptInstances;
        }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM