On page reload, open the special accordion panel

On the accordion panel, I place some data and then reload the page. I would like the reload of the current panel to be open and focused on the screen, rather than re-opening the first panel and moving back to the top of the screen. I know which panel I want to open, so I don’t need the code to understand the panel, just how to display it.

 $.post('<%= ResolveUrl("~/Contract/AddContractLocation") %>', $(form).serialize(), function (data) {
         if (data.Result == "success") {
              ... yada yada... 
              window.location.reload();
         }

Edit to add:

Here's how I initialize the accordion:

$("#acc").accordion({
         autoHeight: false,
         navigation: true
});

This is the basic structure:

<fieldset>
    <legend>Contract</legend>

    <div id="acc">
        <h3><a href="#contractinfo">Contract Info</a></h3>
        <div>
            stuff
        </div>
        <h3><a href="#locationandrs">Locations and Ratesheets</a></h3>   
        <div>
            stuff
        </div>
        <h3><a href="#auditibleterms">Auditable Terms</a></h3>
        <div>
            stuff
        </div>
        <h3><a href="#contractdocs">Contract Docs</a></h3>
        <div>
            stuff
        </div>
    </div>
</fieldset>
+3
source share
3 answers

, - , .

var substr = window.location.href.split('#'); 
window.location.href = substr[0] + "#locationandrs";
window.location.reload();
+3

active true ? "" , :

. false . : .

.

$( ".selector" ).accordion({ active: 2 });

.

//getter
var active = $( ".selector" ).accordion( "option", "active" );
//setter
$( ".selector" ).accordion( "option", "active", 2 );
+1

, . HTML-. js- script:

$('#accordion').accordion({ 
   ...
   ,active: '#panel_selected'
   ...
});
$('#panel_selected').get(0).scrollIntoView(false); // scroll until panel is visible

!

0

Source: https://habr.com/ru/post/1768111/


All Articles