1

I have two buttons VIEW JOB and APPLY JOB . When I click VIEW JOB a modal window appear and contain a button APPLY. When I click the APPLY button in modal the click event of APPLY JOB will called.

<button id="view_job">VIEW JOB</button>
<button id="apply_job">APPLY JOB</button>

button in modal window

<button id="apply_job2">APPLY</button>

$("#apply_job").click(function(){
var jobid=$(this).parent().find(".job").val();
//manage parameter from popup button click
//common code..
});
$("#apply_job2").click(function(){
  $(".jobpanel").parent().find("#apply_job").click(); //here need to pass parameter
});

So when I click both apply job button(in page and in popup) same action is occured (action of apply_job button). But I have to distinguish that from where the action occured. That is, if from popup, I need to do some extra things..So can I pass some parameteres to the button click from popup.

2
  • Yes you can. Please click <> and give us a minimal reproducible example so we can tell you how Commented Jun 14, 2018 at 8:02
  • Without seeing the code, You could do $("#apply_job2").click(function(){ someParameter="someValue"; $(".jobpanel").parent().find("#apply_job").click(); }); and have $("#apply_job").click(function(){ doSomething(someParameter) Commented Jun 14, 2018 at 8:03

1 Answer 1

1

If i understood your problem, you can do with html data attribute:

$("#apply_job").click(function(){
var jobid=$(this).parent().find(".job").val();

 //check if you have added the parameter
 var parameterValue=$(this).attr('data-PARAMETER_NAME');

 if(parameterValue){
   //do something
 }else{
   //do something else
 }
});
$("#apply_job2").click(function(){
  $(".jobpanel").parent().find("#apply_job").attr("data-PARAMETER_NAME","PARAMETER");
  $(".jobpanel").parent().find("#apply_job").click(); 

  //remove atribute here
  $(".jobpanel").parent().find("#apply_job").attr("data-PARAMETER_NAME","");
});
Sign up to request clarification or add additional context in comments.

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.