• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript confirm onclick event using smook.js

 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using smook.js for confirmation from user. i want to get a record id in the javascript function defined for smook.js like below. once user confirms, i can deleted that record.
THis is my JSP script part:

<script>
function tstconfirm(){
smoke.confirm('Are you sure you want to delete this record?',function(e){
if (e){
smoke.alert('Confirmed');
// Want to get the selected record ID here, so that i can call a ajax request to delete the record.
}else{
smoke.alert('Canceled');
}
});
}
</script>
This is my JSP body part:
<div>
<ul id="mytitle">
<li>
<p id="r_id">Record Id</p>
<p id="r_nam">Record Name</p>
<p id="r_des">Record Description</p>
<p id="r_typ">Record Type</p>
<p id="r_action">Delete</p>
</li>
</ul>
<ul id="mylist">
<c:if test="${!empty allrecorddata}">
<c:forEach items="${allrecorddata}" var="recordInfo">
<li>
<a href="editrecord.html">
<p id="r_id">${recordInfo.getId()}</p>
<p id="r_nam">${recordInfo.getName()}</p> // Record Name
<p id="r_des">${recordInfo.getDesc()}</p>
// Record Description
<p id="r_typ">${recordInfo.getType()}</p>
// Record Type
<p id="r_action"><a class="delete" onclick="javascript:tstconfirm();">Delete</a></p>
</a>
</li>
</c:forEach>
</c:if>
</ul>
</div>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can find no information about smook.js; what is it?
 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I can find no information about smook.js; what is it?


http://smoke-js.com/
 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I could able to resolved bit as, on my java script call i m passing the record id as :
onclick="javascript:tstconfirm('${recordInfo.getId()}');"


and java script method written as :

function tstconfirm(recId){
smoke.confirm('Are you sure you want to delete this record?',function(e){
if (e){
smoke.alert('Confirmed');
alert(recid); // This place I am able to get the correct record id
// here i can call the ajax function to delete the record.
}else{
smoke.alert('Canceled');
}
});

Now issue i am facing is alert "Confirmed" and alert(recid) display simultaneously, at this point browser not waiting Confirmed event from user, it goes ahead and print alert(rec id) too. It means that record gets deleted without user select "Confirmed". what if user decide to not to delete it using "Esc" button from key board.
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic