0

I am trying to implement a confirm/alertbox to check before submitting a form. This button is a Bonita submit button. I have very little knowledge of JS/jquery but can understand and implement through trial and error.

Is there an existing out of the box solution for this ? Or if you have any pointers please let me know.

I have referred this : http://community.bonitasoft.com/groups/usage-operation-5x/resolved-confi... , but it is for an older version and is not working for me.

The html page looks like this : ...

<div id="Submit1"></div>

... Details of the auto generated button class in bonita:

div id="Submit1" class="bonita_form_button_entry"> <div class="bonita_form_button_entry"><button type="button" class="bonita_form_button">Submit Documents</button></div></div>

I tried this:

<div id="Submit1" onclick="confirm('Are you sure ?')"></div>

This shows a dialog but continues the operation without waiting for my response. Bonita portal lets me edit the html form. But it needs to be in the format. It automatically generates the button type elements when it loads the page. So I don't have access to button type class.If I did it would be simpler to add the onclick check there.

My problem is propogation of onclick to submit button type. So I can give onclick check only on the top most div type but it doesn't apply to submit button type which is auto generated. Thank you

Hexy
  • 828
  • 14
  • 24
  • Can you edit that div itself in a template or are you looking to run some JavaScript after some form gets generated on the page? – Alfredo Delgado Nov 27 '14 at 02:50
  • I can edit the div. It generates the button type class when it loads. So I want a top down approach where my onlick check on the div propogates to the auto generated button type. – Hexy Nov 27 '14 at 06:50

2 Answers2

0

Give this a try.

  <script>
    window.addEventListener('load', function(ev) {

      document.getElementById('Submit1').addEventListener('click', function(ev) {
        if(!confirm('Are you sure ?')) {
          ev.stopImmediatePropagation();
        }
      }, true);

    }, true);
  </script>

Here's a working example: http://jsbin.com/mazequvuwi/1/edit?html,js,output

Alfredo Delgado
  • 689
  • 4
  • 12
  • Thank you very much, but this is not working in the portal. I think it has something to do with the bonita portal which is not allowing it trigger. – Hexy Dec 02 '14 at 01:19
  • Is the script tag getting stripped out? Is there a public URL to your form that you could share? – Alfredo Delgado Dec 02 '14 at 01:23
  • 1
    Hey Alfredo! Thanks for your help. I cant post the webpage because it is internal to the company.I tried this and it is working : There is a simple button and a submit button. I had to create a simple button which searches for that submit button and executes. I had to hide the submit button. I think this issue is internal to the portal. – Hexy Dec 04 '14 at 09:44
0

The simplest onclick tag on Submit button doesn't work for bonita portal. So I had to work around and put these tags for it to work:

<button type="button" class="btn btn-primary" onclick="if(confirm('Are you sure you want
 to Submit ?')){document.getElementById('Submit')
.getElementsByTagName('button')[0].click()‌​;}">Submit</button> 

Here Submit is a bonitasoft submit type. I have to hide it on the webpage. A regular button calls the above script and indirectly triggers the submit button.

Hexy
  • 828
  • 14
  • 24