Skip to content

Simple HTML example showing glyph with JavaScript constant #662

@incutonez

Description

@incutonez

Hello,

I'm wondering if this is possible. Basically, I have a class like this:

Ext.define('Constants', {
  singleton: true,
  /**
    *  <span class="examples Constants.ICON_ONE_CLS"></span>
    */
  ICON_ONE_CLS: 'my-icon my-icon-one'
});

So I want to reuse my constant to populate the span's class in the example. I can include my Constants singleton, and that's actually on the page (verified that it's present), but what I have above obviously won't work because it's HTML, and it'll be treated as a string. I was trying to figure out a way of listening for the page to render, and then replace all instances with the class examples, but I wasn't able to figure that out... I was thinking something like:
var exampleElements = document.getElementsByClassName('examples');
But that was always an empty array because I'm pretty sure the elements weren't showing when my script was fired.

I then saw the inline examples, and included a dir called extjs-build with the downloaded Ext JS SDK, but then my @example just showed as plain text, like it didn't get parsed.

I'm pretty sure I'm not understanding something so simple. Any help would be appreciated :)

FWIW, I can actually get this working if I do class="my-icon my-icon-one" because I'm also including the stylesheet... I was just hoping I could reuse my constants instead of having to maintain the class names in two places.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions