Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:01:36+00:00 2026-06-13T08:01:36+00:00

I am using CKEditor on a website and I need to be able to

  • 0

I am using CKEditor on a website and I need to be able to put a special data attributes on some of the links created through the editor. The user would indicate that they need the special attribute put on the link by checking a checkbox in the link dialog. I have managed to add a checkbox to the link dialog with the following code:

CKEDITOR.on('dialogDefinition', function(ev) {
    if (ev.data.name == "link") {
        var info = dialog.getContents("info");
        info.elements.push({
            type: "vbox",
            id: "urlOptions",
            children: [{
                type: "hbox",
                children: [{
                    id: "button",
                    type: "checkbox",
                    label: "Button",
                    commit: function(data) {
                        data.button = this.getValue()
                        console.log("commit", data.button, data);
                    },
                    setup: function(data) {
                        this.setValue(data.button);
                        console.log("setup", data.button, data);
                    }
                }]
            }]
        });
    }
});

Now I have two problems. The first one is that despite me adding the code in the commit and setup functions that should save the state of the checkbox, it’s not working. It’s as if the data can’t hold any other parameters but the ones there by default.

The second problem is that I don’t know how to add / remove the data attribute on my links. It seems to me that I should be doing that in my onOk callback on the dialog, however, the link dialog already has an onOk callback, so I’m not sure how I should be proceeding. I, of course, do not want to modify any of CKEditor’s files directly.

How can I accomplish these things?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:01:37+00:00Added an answer on June 13, 2026 at 8:01 am

    You best option is to modify the plugin. So you need to open the source code and find the file links.js in c:\ckeditor_3.6.5\ckeditor\_source\plugins\link\dialogs\

    The source code is quite big (40k) but here you can modify the dialog however you want. When you finish just copy it to your plugins folder, and compress it: http://jscompress.com/

    I have done what you need myself. The whole uncompressed file is here: https://gist.github.com/3940239

    What you need to do:

    First add this line just before the dialog “browse” button is appended. Approx. in line: 547:

                            {
                                id: "button",
                                type: "checkbox",
                                label: "Button",
                                setup: function (data) {
                                    this.allowOnChange = false;
    
                                    if (data.button)
                                        this.setValue(data.button);
    
                                    this.allowOnChange = true;
                                },
                                commit: function (data) {
                                    data.button = this.getValue()
                                    this.allowOnChange = false;
                                }
                            },
    

    This part is actually your code. I just copied and pasted it.

    Then, go to the onOk function, approx. in line 1211: and after commitContent add this code:

    this.commitContent( data );
    
    //My custom attribute
    if (data.button)
        attributes["custom-attribute"] = "button";
    else
        attributes["custom-attribute"] = "";
    

    This will modify your link adding the attribute to the element such as <a href="#" custom-attribute="button">text</a>

    That’s it. Although, you may also like to load the current status of the checkbox. Then, go to the function parseLink . Approx. line 179 to load the attributes:

    ...
    if ( element )
    {
        retval.button = element.getAttribute('custom-attribute');
    
        var target = element.getAttribute( 'target' );
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using CKEditor in Markdown format to submit user created content. I would like
I am using ckeditor to format some data inside my textarea <textarea id=editorAbout rows=70
I am using CKEditor for my wysiwyg editor and I need to monitor and
I'm using CKEditor to created the portion of my CMS for the user to
I'm using CKEditor as a rich text editor for my website. On that site
I'm using CKEditor and would like to be able to allow users to upload
I am creating an editor in asp.net MVC application using ckeditor. In textarea i
I am using GWT-CKEditor for my application. And I want to test it through
I'm currently working with ckeditor and i'm using the jquery plugin for this editor
i am using rails 3.0.3 and i recently installed ckeditor to add text editor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.