Back Button

Need to know how to code a "back one" button that functions as: history.back(-1). We need a button within the app for backing up one screen vs. using the device back button. Thanks in advance for any help with this task.

This should get you what you want. Add the class hBack on a button or link or really can be put on anything you want to trigger the back in browser history function. I used a class simply because you can then have more than 1 area if you want to trigger it.

HTML

<button class="btn btn-primary hBack" type="button">Button</button>

JS

$(".hBack").on("click", function(e){
    e.preventDefault();
    window.history.back();
});

Saj

UPDATE: Just to let you know that you CSS Class and JS worked just fine to create a functional "back -1" button. We created the JS file, then added the Class to the button link, and the button, and it worked perfectly. Thank you very much for the code. HERB

Your welcome glad I could help :)

Saj

This helped me as well! Thank you so much for helping out!

Another way to do it is through the attributes panel

or the options panel

Thanks for the tip! I’m going to give this a try as well. Although I got the other method to work, yours looks like a much easier option. I did add the back button to my Library so I can use it on a click and drag now, but your method looks much easier for the initial setup.

Always appreciate those of you that know more, helping out us that are much less experienced.

So here is me hopefully helping someone too, in case they didn’t already know about the “add to Library”.

Once you create custom code like the back button in the above example, you can right click on it in the Overview panel and select “Add to Library”.
Add to Library

It will then pop up a window where you will select the js for it to package with the library component.

This will then add it to your library for future use by just dragging and dropping it like the other library components.
Library

Regards,
Blain