0

i added alertify to my project to enhance some visuals and overide the time on the standard prompt of the browser however the code doesnt work on firefox it works on chrome please see below :

         xFunction = function() {
         event.preventDefault();
      alertify.confirm("Are you sure? This cant be undone!!?", function(e) {
      if (e) { 
     alertify.success("Asset Discontinued Successfully!!");
      $('#conf').click()  } else {
alertify.success("Nothing was Discontinued!!");
    }
    });
    }

and for the html

  <form action='Allocated.php' method='post' name='disc' id='conf' >
<input type='submit' name='disc' value='Discontinue Asset' formnovalidate='formnovalidate' id='conf' onclick='return xFunction() ;' />
TeeJay
  • 119
  • 2
  • 8
  • Have you checked for errors in console? Have you inserted breakpoints in the code to help debug which part might be broken? What specifically "doesn't work", meaning what behavior do you see or not see? – scrappedcola Feb 27 '17 at 20:35
  • it submits the form asif there is no script – TeeJay Feb 27 '17 at 20:38
  • Did you check that `event` is defined? Firefox has had behavior differences from chome http://stackoverflow.com/questions/4585970/jquery-event-preventdefault-not-working-in-firefox-jsfiddle-included – scrappedcola Feb 27 '17 at 20:43
  • where to add it in my code i tried adding the click without the function it didnt work can you please clarify ? – TeeJay Feb 27 '17 at 20:46
  • If you need help on getting started with debugging you should check out the documentation on debugging: http://stackoverflow.com/documentation/javascript/642/debugging#t=201702272054349893235. First step is to see that `xFunction` is being called. At the top of that function add either a console.log or alert to see if it's even being called. Also hit f12 to see if there are any errors in the console. – scrappedcola Feb 27 '17 at 20:56
  • i just need help with where to put the event if its not initialized. thats all first place am not that good in front end coding sorry i just need this sorted – TeeJay Feb 27 '17 at 20:57
  • http://stackoverflow.com/questions/16404327/how-to-pass-event-as-argument-to-an-inline-event-handler-in-javascript – scrappedcola Feb 27 '17 at 20:58
  • thanks for that still dont know where to put the event dont bother in pasting more links thanks anyways i just need some help where to paste it in my code :) thanks anyways u were great – TeeJay Feb 27 '17 at 21:06
  • Did you read the answer to the second one? it's the same onclick that you have inline on your input. Use it as an example to pass the event object from the onclick to your function – scrappedcola Feb 27 '17 at 21:17
  • i tried and added this and still not working and in html i put xFunction(event) and in script function xFunction(e) { e = e || window.event; var target = e.target || e.srcElement; event.preventDefault(); alertify.confirm("Are you sure? This cant be undone!!?", function (e) { if (e) { alertify.success("Asset Discontinued Successfully!!"); $('#conf').click() } else { alertify.success("Nothing was Discontinued!!"); } }); } – TeeJay Feb 27 '17 at 21:21
  • `event.preventDefault();` would change to `e.preventDefault()`, which is what you named it `function xFunction(e)` – scrappedcola Feb 27 '17 at 21:31
  • yes i changed that too still it shows the msgbox in both browsers but now doesnt do the code $('#conf').click() – TeeJay Feb 27 '17 at 21:36
  • which isn't valid on a form. You should use `$("#conf").submit()` – scrappedcola Feb 27 '17 at 21:44
  • yes i know it was working on chrome now it doesnt work on both chrome and firefox i tried too submit still no work i hate this project – TeeJay Feb 27 '17 at 21:47
  • `return true` rather than submit, `return false` in your else case. – scrappedcola Feb 27 '17 at 22:00
  • alertify works on callback functions return true doesnt work with it – TeeJay Feb 27 '17 at 22:07
  • am gonna sleep now thank you i was really boring and i know front end coding isnt my thing hope i sort it out tomorrow thanks again man u been great – TeeJay Feb 27 '17 at 22:08
  • any help would be appreciated – TeeJay Feb 28 '17 at 16:28

0 Answers0