Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

javascript - M-Files plugin: DOM style changes not reflect by page

I'm creating a plugin for M-Files. It's based on jquery, the browser is embedded in the windows explorer window. For some reason, I'm unable to change the style properties of simple HTML elements. Value is changed, but other than text color, no change is reflected by the view.

Element creation

               // Create element for title.
               $("<p class='mf-widget-newobject-title'>" + title + "</p>").appendTo(this.element);
               // Create element for news
               $("<p class='mf-widget-newobject-news'>" + news + "</p>").appendTo(this.element);
               // Create element for standart text
               $("<p class='mf-widget-newobject-standart'>" + standard + "</p>").appendTo(this.element);
               // Create elements for content.
               $("<div id='mainDiv' class='new-section-content'></div>")
                   .append("<ul></ul>")
                   .appendTo(this.element);

This works fine!

Style changes

                var x = document.getElementsByClassName('new-section-content');
                var i;
                for (i = 0; i < x.length; i++) {
                    x[i].style.columncount = columns;
                    alert(x[i].style.columncount);
                }

                var x = document.getElementsByClassName('mf-widget-newobject-title');
                var i;
                for (i = 0; i < x.length; i++) {
                    x[i].style.color = headlineColor;
                    x[i].style.fontsize = headlineSize + "px";
                    alert(x[i].style.fontsize);
                }
                var x = document.getElementsByClassName('mf-widget-newobject-standart');
                var i;
                for (i = 0; i < x.length; i++) {
                    x[i].style.color = standardColor;
                    x[i].style.fontsize = standardSize + "px";
                    alert(x[i].style.fontsize);
                }

This, however. "Color" is changed without a problem. As for font-size and column-count, the value is changed (Alert return right value), but nothing happens in the view.

Am I missing something? I'm not really good at javascript but it seems like I have everything right...

Thanks!

question from:https://stackoverflow.com/questions/66047482/m-files-plugin-dom-style-changes-not-reflect-by-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try fontSize and columnCount. JavaScript is case sensitive.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...