简体   繁体   English

使用Jquery / Javascript将大括号别名插入表单

[英]Insert into form curly brackets alias with Jquery / Javascript

I am not even sure if this is even possible or how easy it is, but what I am trying to work out is how to, if it is possible, to use jquery or javascript to insert an alias for a form field / curly brackets where the cursor currently is selected on the page. 我什至不确定这是否可行或有多么容易,但是我试图解决的是如何(如果可能)使用jquery或javascript为表单字段/大括号插入别名,其中当前在页面上选择的光标。

Let me try and explain it a bit better....... 让我尝试更好地解释它.......

So I go to the email template form, on the right of the form I have 3 buttons, 因此,我转到电子邮件模板表单,在表单右侧,我有3个按钮,

NAME , REP , DATE
Name = {leadname}
Business Name = {businessname}
Date = {datesent}

These are all form fields being posted into the $form->data array when it loads. 这些都是在加载时将所有表单字段发布到$ form-> data数组中的。

I start writing out my template so.......Dear {leadname} etc etc when the template is sent, it loads the clients name etc into the curly brackets and sends it in an email. 我开始写模板,.......亲爱的{leadname}等在发送模板时,它将客户名称等加载到大括号中并通过电子邮件发送。

What I am trying to do is make this so that someone doesnt write leadname for the persons name but presses the button to the right of the form marked 'Name' , this then inserts [Name] or maybe Name in bold into the form, but this is actually an alias of {leadname} , so im not sure if I have to change my language file too to get this to work ?, im also not sure how to actually insert these fields into my template form field. 我正在尝试做的是使某人不为个人姓名写主角名称,而是按标记为“姓名”的表格右侧的按钮,然后在表格中插入[姓名]或粗体的姓名,但是这实际上是{leadname}的别名,所以我不确定是否也必须更改语言文件才能使其正常工作?,我也不确定如何将这些字段实际插入到模板表单字段中。

Is this kind of what you're talking about doing? 您是在说这种事吗? http://alexking.org/projects/js-quicktags/demo/index.html http://alexking.org/projects/js-quicktags/demo/index.html

If so, I think this guys implementation of JavaScript quick tags will get you going: http://alexking.org/blog/2004/06/03/js-quicktags-under-lgpl/ 如果是这样,我认为这家伙的JavaScript快速标记实现将带您进入: http : //alexking.org/blog/2004/06/03/js-quicktags-under-lgpl/

Otherwise, this post may help you out: Inserting a text where cursor is using Javascript/jquery 否则,本文可能会为您提供帮助: 在使用Javascript / jquery的游标中插入文本

- -

Edit 编辑

Here's the code you need, using Alex King's plugin to create a button that doesn't get closed: 这是您需要的代码,使用Alex King的插件创建不会关闭的按钮:

edButtons.push(
    new edButton(
        'leader_name'
        ,'LEADER'
        ,'{leadname}'
        ,-1
        ,-1
    )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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