Home  >  Q&A  >  body text

javascript - When you click delete, a prompt box will be prompted to confirm whether to delete. After clicking OK, the ajax event will be executed. How to implement this?

Click delete, and a prompt box (modal box) will be prompted to confirm whether to delete. After clicking OK, the ajax event will be executed. How is this implemented?

I am new to front-end content, and the source code for the implementation of this pop-up box has not been found.

delete

is a pop-up box with fixed style through class="js-ajax-dialog-btn".

Searched for two pieces of jquery code $(.js-ajax-dialog-btn").... Even if it is blocked, there will still be a pop-up box.

The ideas of the bosses are very good, thank you!

Because the cache is too powerful, the code I found is correct and I changed the source code. .

淡淡烟草味淡淡烟草味2673 days ago1401

reply all(6)I'll reply

  • ringa_lee

    ringa_lee2017-06-26 10:59:50

    Confirm Yes or No to execute ajax!

    reply
    0
  • 高洛峰

    高洛峰2017-06-26 10:59:50

    Determine whether the returned true or false
    true executes ajax
    false and closes the modal box
    then it is ok.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-26 10:59:50

    If you don’t pursue results, just

     var result=confirm("是否删除?");
     if(result==true){//do something}
    

    If you want something beautiful, look for various UI libraries and you will find this, for example
    https://ethaizone.github.io/B...

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-26 10:59:50

    When you click delete, only bind the event of the pop-up prompt box. In the pop-up box, bind the event for the confirmation button and make the corresponding ajax request.

    reply
    0
  • 为情所困

    为情所困2017-06-26 10:59:50

    When you click delete, a modal box pops up, and then bind the ajax event to the confirmation button, then you can click OK to execute asynchronously.

    reply
    0
  • 怪我咯

    怪我咯2017-06-26 10:59:50

    It is recommended to use the layer plug-in, which is simple and convenient.
    prompt example:

    layer.open('Cloase?',{yes : function(){
    
    }
    },cancel : function(){
    
    });

    reply
    0
  • Cancelreply