0

I have a small issue:

I have a jquery onclick event set for a row() in a table and in the last column I have a link that opens a confirmation pop-up(asking if I am sure to do that bla bla . . .). If I click the link, the pop-up opens, and if I press no, it should stay on the current page, but instead it continues with the event from the row(that click is triggered). What do you think?

Link:

<tr class="clickableRow" id="someId"> bgcolor="color">
   ..........
    <td>
     <a  href="javascript:void(0)" onClick="javascript:del_prompt('url');">                        <img src="images/delete.png" border="0"></a>
</td>
</tr>

Javascript:

  $(".clickableRow").click(function() {
   window.open("companynewestimate.php?id="+this.id,"_parent");
  });

Del function

<script language="javascript">
function del_prompt(id)
{

        if(confirm ("Are you sure you want to delete selected Record")){
            location.href = "companyopenestimates.php?act=del&id="+id;
            }
        else{ 
            return false;
        }

        }



</script>
2
  • Sounds like not returning false from the click handler is the issue. But can't say for sure without seeing your code. Commented Mar 29, 2013 at 11:57
  • I want to trigger the popup and after, if I click no, not to follow the jquery event...I've posted some code...thank's Commented Mar 29, 2013 at 12:06

2 Answers 2

2

Without some code, it's hard to get the correct answer. But maybe this helps:

  $("#element").on("click",function(e){
     //do something
     e.preventDefault();
     e.stopPropagation();
  })

See here: http://api.jquery.com/event.stopPropagation/

Sign up to request clarification or add additional context in comments.

2 Comments

I want to trigger the popup and after, if I click no, not to follow the jquery event...
yeah, so you still could use preventDefault and stopPropagation. If the user clicks no, you could trigger a new click event. By the way, it's actually not a good idea to use a popup. Maybe an overlay would be better. Or an alert box or something.
0

Changing your link's onclick should do the trick:

onClick="del_prompt('<?=$line['id_est']?>'); return false;"

Note that the javascript: is not at all needed.

1 Comment

can you post your del_prompt() function? Maybe the problem is in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.