cotestatnt / esp-fs-webserver

ESP32/ESP8266 webserver, WiFi manager and web editor Arduino library
MIT License
120 stars 29 forks source link

Is possible to add more than one custom_html? #30

Closed arimukhlas closed 10 months ago

arimukhlas commented 1 year ago

hi @cotestatnt

I want to add 2 custom addOptionBox,

I try this on sketch,

  myWebServer.addOptionBox("Summary Result");
  myWebServer.addHTML(custom_html1, "fetch-test", /*overwite*/ true);
  myWebServer.addCSS(custom_css, /*overwite*/ false);
  myWebServer.addJavascript(custom_script, /*overwite*/ false);

  myWebServer.addOptionBox("About Me");
  myWebServer.addHTML(custom_html2, "fetch-test", /*overwite*/ true);
  myWebServer.addCSS(custom_css, /*overwite*/ false);
  myWebServer.addJavascript(custom_script, /*overwite*/ false);

and this on customelement.h

static const char custom_html1[] PROGMEM = R"EOF(
    <main class="container">
      <article class="grid">
        <div>
          <p id="esp1">T E S T 1</p>
        </div>
      </article>
    </main>
)EOF";

static const char custom_html2[] PROGMEM = R"EOF(
    <main class="container">
      <article class="grid">
        <div>
          <p id="esp2">T E S T 2</p>
        </div>
      </article>
    </main>
)EOF";

but the page is only show on last option box Is possible to add more than one custom_html on different optionBox?

thanks

cotestatnt commented 1 year ago

You need to set 2 different id for ech section

myWebServer.addHTML(custom_html1, "fetch-test1", /*overwite*/ true);
myWebServer.addHTML(custom_html1, "fetch-test2", /*overwite*/ true);