Saving JavaScript code in <Head> after ASP.Net returns.

As the name implies, I am having problems saving my code during postback. I have a bunch of jQuery code in the "Head" section, and this works fine until the postback happens, after which it stops functioning!

How can i fix this? The head cannot be read after the postback, and is there a way I can make this happen?

JavaScript:

        <script type="text/javascript">
        $(document).ready(function()
        {
            $('.tablesorter tbody tr').tablesorter();

        $('.tablesearch tbody tr').quicksearch({
            position: 'before',
            attached: 'table.tablesearch',
            stripeRowClass: ['odd', 'even'],
            labelText: 'Search:',
            delay: 100
        });
       }); 
        </script>
+3
source share
5 answers

, . (FireBug FireFox - ):

  • , script .
  • , css .
  • , jquery , .

EDIT: UpdatePanels ? , ?

EDIT EDIT: AHhhhh... . , UpdatePanels, , jquery . jquery , async.

+6

function pageLoad(sender, args) {

    /* code here */

}

$(document).ready(function() { ... });

pageLoad() - , , . .

+2

, postback pre-empts onLoad , jQuery .ready().

+1
  • script HTML ?
  • , ? , alert('test');
  • , , , ?
+1

Instead of using $ (document) .ready you should put your code in a function called pageLoad (). The pageLoad () function is wired, which will be called whenever the page has a / asyncpostback postback.

0
source

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


All Articles