Jquery Mobile Onclick event does not work before page reload

Jquery Mobile Onclick event does not work before page reload

Hi,

I am calling page from main page but the onclick does not work until I reload the page.
any help? 

This is my link:
<a href="#" id="mag" data-role="button" onclick="formSubmit();"> <img src="images/mag.jpg" alt="" /> </a>

This is javascript:
  1. $('#mag').click(function (event) {
    formSubmit();
    });
    $(window).load(function () {
    $("#q").keyup(function () {
    var SEARCHWORD = this.value;
    $("#MAIN_UL li").each(function () {
    if ($(this).
    find("a").
    text().toUpperCase().
    indexOf(SEARCHWORD.toUpperCase()) >= 0)
    $(this).show();
    else
    $(this).hide();
    });
    });
    });