-1

In an existing application I have the option to add some jQuery code, but cannot change the existing code. The application has several buttons with unique ID's. Now based on which button is clicked I would like to trigger an additional event next to the standard onclick function.

The default button code is:

'<button id="btnReopen" class="exButton" type="button" onclick="SysSet('BCAction', 7); SysSet('IgnoreValidationErrors', 1); SysSet('RQ_Reopen', 1); SysSet('Status', 0); SysSubmit(); fnSaveForm();" onmouseover="this.className='exButtonOver'" onmouseout="this.className='exButton'" onmousedown="this.className='exButtonDown'" accesskey="3" title="ALT 3 - Reopen" style="vertical-align:middle;"><span>Reopen</span></button>'

What I would like is that when this button is clicked an additional window is launched with a specific url. I tried something like the script below, however that triggers immediately on page load and in the same window

<script type="text/javascript">
    jQuery( document).delegate( "#dCalc input[type='button']", "click",
        function(e){
        var idClicked = this.id;
    });

    if(idClicked = "BtnReopen") {
        window.location="WflRequest.aspx?BCAction=0&Type=0&Description=Hello";
    };
</script>
Luke Peterson
  • 8,584
  • 8
  • 45
  • 46
  • `var idClicked` is local to click handler. If you are using already an outscoped variable `idClicked` as your code suggests it, then remove `var` statement in `var idClicked = this.id;`, so `idClicked = this.id;`. That's said, your posted code logic doesn't really make sense here, missing some context to make it clearer – A. Wolff Mar 08 '15 at 10:11
  • Thanks for replying. I believe you if you say the code doesn;t make sence. Whant context do you need? Basically I have 2 issues to solve. 1) how to make a click on a specific button trigger an event, which is the tough one for me. 2) how to open the event in a new window. I'm confident that I can figure out 2, but for the first 1 would appreciate help. – Cees Meuleman Mar 08 '15 at 10:31

2 Answers2

0

.delegate() has been obsolete for a while. You should use .on() instead:

    <script type="text/javascript">
jQuery( document).on( "click", "#dCalc input[type='button']",
    function(e){
    var idClicked = this.id;
});
if(idClicked = "BtnReopen") {
window.location="WflRequest.aspx?BCAction=0&Type=0&Description=Hello";
} ;
</script>
Scimonster
  • 32,893
  • 9
  • 77
  • 89
0

When the button is clicked :

<script type="text/javascript">
jQuery('#btnReopen').click( function () {
     window.open('WflRequest.aspx?BCAction=0&Type=0&Description=Hello', '_blank');
});
</script>
Mauritius
  • 105
  • 2
  • 7