jQuery Delete Confirmation |
[eluser]Kemik[/eluser]
Hello, I have a user list and want to create a pop-up asking the admin to confirm if they want to delete the user when they click on a link. It seems jQuery is a popular Javascript library so I'm looking for something based on that. I've looked around google and the jQuery site for some sample code but haven't had much luck. If anyone knows any good resources I'd appreciate it. Thanks.
[eluser]Alex007[/eluser]
Why not just a simple Javascript Confirm() ? My "delete" link looks like this: Code: <a href="#" onclick="return deletechecked();">Delete checked messages</a> Which points to this javascript function: Code: function deletechecked() Which submits the form, and the messages are deleted.
[eluser]xwero[/eluser]
do you want the common modal window. The only thing you need is a class Code: $('.delete').click(function(){
[eluser]Kemik[/eluser]
Thanks guys. To pass a variable could I just do: Code: <a href="#" onclick="return deletechecked('Are you sure you want to delete <?=$row->username ?>');">Delete checked messages</a> Code: function deletechecked(message)
[eluser]Unknown[/eluser]
Hi, I'm new to CodeIgniter and I like it a lot. [quote author="xwero" date="1201829209"]do you want the common modal window. The only thing you need is a class Code: $('[b].delete[/b]').click(function(){ [/quote] Thank you xwero. Using jQuery, I added in CI a class to anchor and it worked. Code: echo "<td>". anchor('controller/delete/'.$row->id,'Delete',array('class' => 'delete')) ."</td>"; The good is that jQuery is unobtrusive. PS: I figured out how to get with jQuery anchor attributes jQuery function Code: $(document).ready(function(){ anchor in ci view file Code: echo "<td>". anchor('controller/delete/'.$row->id,'Delete',array('class' => 'delete', 'title'=>"$row->username")) ."</td>";
[eluser]Dave Rau[/eluser]
Hey guys, I'm doing something similar but I'd like to use better URLs instead of just href="#", anyone have any advice on that? I tried jquery confirm, but I can't get my parent TR to hide after I OK the delete: Code: $('a.delete').click(function(event) { anyone have any thoughts?
[eluser]cahva[/eluser]
You can use any href as you wish. You just have to return false always. Taken from example earlier: Code: function deletechecked(message)
[eluser]cahva[/eluser]
Actually that line is not needed in that particular example because that indeed returns false always even if the confirm was cancelled(return false is outside the if). My bad. But anyways, the return always false was the point
[eluser]Unknown[/eluser]
Hi Guys i'm New to this CodeIgniter that delete conformation is not working for me it is firing before i delete any record(i gave a simple alert in it).i wrote that code in the same view page is that correct please reply fast this is my code Code: [removed] Code: echo "<td >".anchor('all/delete/'.$row->newsid, 'Delete', array('class' => 'delete', 'title'=>"$row->newsid"))."</td>"; |
Welcome Guest, Not a member yet? Register Sign In |