oveits / ProvisioningEngine

Ruby on Rails based ProvisioningEngine Frontend for provisioning of legacy systems via Apache Camel Backend (SOAP/XML+SPML+File import)
3 stars 6 forks source link

Page reload function causes a page to toggle back to the previous page sporadically #61

Closed oveits closed 7 years ago

oveits commented 8 years ago

When clicking from one dynamically reloaded page to another, the page seems to be reloaded back to the previous one.

Best to reproduce on cloud9, running the app with

rails s -p $PORT -b $IP

You might need to toggle back and forth between the customer page and the site page using the browser navigation (on Chrome on Windows, you can use Alt + arrow right and Alt + arrow left to do so). In the moment, I am toggling back and forht between https://provisioningengine-oveits.c9users.io/customers/2 and https://provisioningengine-oveits.c9users.io/sites/2.

oveits commented 8 years ago

Today, all pages use the same DOM IDs on all pages. Currently, I search for this non-unique ID in the javax answer and I replace the corresponding DOMelement with the same ID.

It is better to introduce a new class named "tefresh", have unique IDs on the page and replace same ID by same ID for each element of the class "refresh".

The following snippet might help to find the right function names:

html part: html element that I want to replace needs a class named "refresh" and needs a unique ID:

<element class="class1 class2 refresh" id="uniqueID"> ... </element>

(get same page as var named data using javax)
var elementsToBeRefreshed = document.getElementsByClassName("refresh");
// init for parsing the data retrieved via javax:
var parser = new DOMParser();
var doc = parser.parseFromString(data, "text/html");
(loop over i)
    var id = elementsToBeRefreshed[i].getAttribute('id');
    (if id is not empty)
        // calculate newhtml:
        var newhtml = doc.getElementById(id).innerHTML;
        // refresh element:
        elementsToBeRefreshed[i].innerHTML = newhtml;
    (end if)
(loop end)