0

I have the following function in Javascript:

$find('mainWindow').repaint();

I need to run that inside this jQuery function:

    $("#tools").click(function() {
        if(get_cookie('visible')== null) {
            set_cookie('visible','no',2020,1,1,'/','.domain');
            $("#WinMain").animate({top: "25px"}, 200);
            **<!--INSERT FIND-->**
        } else {
            delete_cookie('visible','/','.domain');
            $("#WinMain").animate({top: "89px"}, 200);
            **<!--INSERT FIND-->**
        }
0

3 Answers 3

1

A click handler is just that, an event handler...no one said you can have only one :) If multiple are attached, they'll run in the order they were bound...so if you can't modify that function, just attach your own .click() handler after the current one, like this:

$("#tools").click(function() {
  if(get_cookie('visible')== null) {
    set_cookie('visible','no',2020,1,1,'/','.domain');
    $("#WinMain").animate({top: "25px"}, 200);
  } else {
    delete_cookie('visible','/','.domain');
    $("#WinMain").animate({top: "89px"}, 200);
  }
});
//add your own handler later:
$("#tools").click(function() {
  $('#mainWindow').repaint();
});

I'm not really sure what $find('mainWindow') stood for, so I'm doing a bit of guessing in the handler above, grabbing it by ID. If you can modify the original handler, just stick the code you want to run in where you have placeholder comments now now.

Sign up to request clarification or add additional context in comments.

Comments

0

jQuery is JavaScript, so you can just insert your JavaScript call:

$("#tools").click(function() { 
    if(get_cookie('visible')== null) { 
        set_cookie('visible','no',2020,1,1,'/','.domain'); 
        $("#WinMain").animate({top: "25px"}, 200); 
    } else { 
        delete_cookie('visible','/','.domain'); 
        $("#WinMain").animate({top: "89px"}, 200); 
    }
    $find('mainWindow').repaint(); 
});

Note that I have put it after the if statement, as you wanted it put in both the true and false branch of the if statement.

Is there more to your question?

Comments

0

Why not just

    $("#tools").click(function() {
        if(get_cookie('visible')== null) {
            set_cookie('visible','no',2020,1,1,'/','.domain');
            $("#WinMain").animate({top: "25px"}, 200);
        } else {
            delete_cookie('visible','/','.domain');
            $("#WinMain").animate({top: "89px"}, 200);
        }
        $find('mainWindow').repaint();

? Does this not work? What problems are you having?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.