在SugarCRM 6.5中添加带有自定义JavaScript的按钮 [英] Adding a button with custom JavaScript in SugarCRM 6.5

查看:105
本文介绍了在SugarCRM 6.5中添加带有自定义JavaScript的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在一个详细视图中添加一个按钮.此按钮应该打开一个弹出窗口,该弹出窗口将从服务中加载一些数据,显示这些信息,等等(此时不重要).

I need to add a button to one of my detail views. This button should open a pop-up, which loads some data from a service, displays it, etc ( not important at this point).

我设法使用Sugar中的vardefs机制添加了按钮.然后,我尝试为按钮添加一些逻辑.那就是我被困住的地方.

I have managed to add the button using the vardefs mechanism in Sugar. Then I tried to hook some logic to the button. That's where I got stuck.

我发现了有关如何进行此操作的建议:

I found this advice on how to proceed: https://community.sugarcrm.com/thread/28658-how-can-i-add-custom-button-next-to-save-cancel-on-account-module-and-custom-module#comment-84253

添加按钮的方式与对我有用的方式相同,因此似乎合法.

The way the button was added was the same as what has worked for me, so it seemed legit.

问题在于添加外部脚本文件-jQuery和我的自定义脚本文件.该部分似乎不起作用.当我加载页面并单击按钮时,我得到

The problem is with adding the external script files - jQuery and my custom script file. That part doesn't seem to work. When I load the page and click the button, I get

RefereneError: myButtonFunt is not defined

示例中的路径是相对的(它们以./开头),我试图推断文件在项目中的位置.我尝试了几件事,最后我只输入了绝对路径(从SugarCrm的根文件夹开始):

The paths in the example are relative, (they start with ./), and I tried to extrapolate for where the files are located in my project. I've tried several things, in the end I just put in absolute paths (starting at the root folder of SugarCrm) :

 array (         
        'javascript' => '        
                     <script src="/custom/include/javascript/jquery-1.4.4.min.js" type="text/javascript"></script>  
                     <script src="/custom/modules/Cases/scripts/detailview/additionalInfoPopup.js" type="text/javascript"></script>  
                ',  
             ),

什么都行不通.通过直接在浏览器中导航到文件,我已经验证了文件是否正好指向路径指向的位置.我什至尝试将路径更改为"./somefile.js",并将文件放置在detailviewdefs.php文件所在的文件夹中(我决定跳过jQuery参考,因为加载页面时存在jQuery,并且它是比我尝试包含的版本新的版本).没有.函数myButtonFunt是未定义的.我引用的文件似乎未加载到浏览器的dev工具中.查看页面的源代码,没有提及我的js文件.

nothing works. I have verified that the files are exactly where the paths are pointing, by navigating to them directly in the browser. I've even tried changing the path to "./somefile.js" and placing the file in the same folder where the detailviewdefs.php file is (I decided to skip the jQuery reference, because when the page is loaded jQuery is present - and it's a newer version than the one I'm trying to includE). Nothing. Function myButtonFunt is undefined. The file I've referenced doesn't seem to be loaded in the browser's dev tool. Looking at the source of the page there is no mention of my js file.

显然,该示例是为editviewdefs.php制作的,而我正在detailviewdefs.php中使用它,但是在我看来,它似乎无关紧要.在我的detailview.php中,templateMeta数组以

Obviously the example was made for editviewdefs.php, and I'm using it in detailviewdefs.php, but it seems to me like it shouldn't matter. In my detailview.php the templateMeta array starts with

'form' => array (...

我尝试将我的javascript数组放入和放出表单数组.两种方法都行不通.

I have tried putting my javascript array both in and out of the form array. Neither approach worked.

我不知道该怎么办.在这一点上,我可以接受任何包含我的js文件的方法,以便按钮可以触发它.任何帮助将不胜感激.

I have no idea what to do. At this point I would be ok with any approach that would include my js file so that the button can trigger it. Any help would be appreciated.

推荐答案

SugarCRM 6.5很古老,所以我希望我没记错:

SugarCRM 6.5 is ancient, so I hope I remember this right:

我相信您应该在该部分中使用实际的JavaScript,而不是在做什么(HTML脚本标签).

I believe you are supposed to use actual JavaScript in that section, rather than what you are doing (HTML script tags).

因此,也许可以尝试类似的方法(通过使用JavaScript加载外部JavaScript):使用Javascript加载其他外部Javascript

So maybe try an approach similar to this (loading external JavaScript by using JavaScript): Using Javascript to load other external Javascripts

这篇关于在SugarCRM 6.5中添加带有自定义JavaScript的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆