osselosse
osselosse

Reputation: 149

how to call jconfirm jquery from js file

i call JCONFIRM inside my JS file but doesnt work :

jConfirm('Title', 'Are you sure?', function(r) {     
if(r)
{
alert("true");
}
else
{
alert("false");
}
 });

did i miss any lib ?

Upvotes: 1

Views: 8345

Answers (2)

osselosse
osselosse

Reputation: 149

this is a simple example that i used but doesnt work

Updated :

idk why Jconfirm doesnt work

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
        <link rel="stylesheet" type="text/css" href="css/jquery.alerts.css" media="screen" />
        <script src="js/jquery-1.9.1.js"></script>
        <script src="js/jquery.alerts.js"></script>
        <script>
$(document).ready(function(){
  $("#btn1").click(function(){
    jConfirm('Title', 'Are you sure?', function(r) {     
if(r)
{
alert("true");
}
else
{
alert("false");
}
 });
  });

  $("#btn2").click(function(){
     alert("test");
  });
});
</script>
    </h:head>
    <h:body>

<button id="btn1">Append text</button>
<button id="btn2">Append list items</button>
    </h:body>
</html>

thats what i get when i click on "Append text" enter image description here

still doesnt work

Update 2 : i added Jquery 1.6.1 and it works thats what i get : enter image description here

why i have this A OK A ???

Update 3: problem fixed i changed in jquery.alerts.js this :

okButton: ' OK ',
cancelButton: ' Cancel ',

to this :

okButton: 'OK', cancelButton: 'Cancel',

Upvotes: 0

Surendra Jnawali
Surendra Jnawali

Reputation: 3240

I think your syntax is correct
You have to following library to be work

  • jquery-1.8.3.min.js
  • jquery.alerts.js
  • jquery.alerts.css
    Download Link
    jquery.alerts.css - bvbcode
    jquery.alerts.js - bvbcode

Upvotes: 1

Related Questions