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 8681101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:25:04+00:00 2026-06-12T21:25:04+00:00

I am trying to add a custom id attribute for each img & input

  • 0

I am trying to add a custom id attribute for each img & input elements in ckeditor 3.6.4.
So far I have added dataProcessor.htmlFilter to handle the id attribute like this

        CKEDITOR.on( 'instanceReady', function(event) {     
            var editor = CKEDITOR.instances.editor;

            editor.dataProcessor.htmlFilter.addRules(
            {
                elements: {
                    $: function (element) {
                        if ( (element.name == 'img' || element.name == 'input') && CKEDITOR.instances.editor.mode == 'wysiwyg' ) {
                            if (!element.attributes.id){
                                var g = createID();
                                alert('new id: ' + g);
                                element.attributes.id = g;
                            }
                        }

                    }
                }
            });
        });

and when I add a new textfield in visual editor I do get a new id. But if I set to the source mode the mode is still ‘wysiwyg’ and not ‘source’ and it gives a new Id.

How can I prevent the double action?


Did some testing. Added this

CKEDITOR.instances.editor.on('mode', function() {
            // Code to execute when the user switches editing modes
                alert('Changed to: ' + CKEDITOR.instances.editor.mode);
            });

Somehow that fires after the htmlFilter rule.

  • 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-12T21:25:05+00:00Added an answer on June 12, 2026 at 9:25 pm

    Went with plan B

    Customized the widgets needed and added the id attribute in plugin. Was easy and fast.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a custom attribute on my element using jquery : $('.map-areas-div').rand(numElements).each(function(){
I am trying to add a custom data-required attribute to an asp Checkbox control,
I'm trying to create a custom attribute for each list item in a databound
I'm having a problem trying to add a custom HTML5 data attribute to the
Trying to add a column with a custom attribute to the admin customer grid
I have a custom view, extending LinearLayout and im trying to add some custom
I am trying to add custom icons to a Shared Add-in for Microsoft Word.
I'm creating a custom WP theme and trying to add custom menus to the
I'm trying to add a custom class to the jQuery Mobile theme. The CSS
I am trying to add a custom log handler to my java application. I

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.