confirm

custom choices in javascript confirm dialog

久未见 提交于 2019-11-27 02:08:11
How to write a confirm dialog in javascript with custom choices? Instead of just "Ok" and "Cancel", I would like to have for example "This" "That" and "Other". In short, you can't. You might want to consider looking into using something like a jQuery UI dialog instead. You could ask the user for an answer using: var userChoice = prompt("Question"); You could loop that sentence until the user enters an answer within the valid ones. You can't. Use some javascript UI (jQuery UI, YUI, Mootools) library and mimic a dialog you need. // custom Confirm builder function OnConfirm(text, func) { var

Android - Confirm app exit with toast

人盡茶涼 提交于 2019-11-27 01:41:12
问题 I'm new to Android development and I want it so when the user presses the back button on the main activity, a toast message appears with a "confirm exit by pressing the back button again" message. How would I do this? This is what I have so far: @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); Toast s = Toast.makeText(getBaseContext(), "Press back again to exit", Toast.LENGTH_LONG); s.show(); wait(); public boolean onBackPressed() { finish(); }

RabbitMQ事务和Confirm发送方消息确认

萝らか妹 提交于 2019-11-26 23:51:47
引用: https://www.cnblogs.com/vipstone/p/9350075.html 引言 根据前面的知识( 深入了解RabbitMQ工作原理及简单使用 、 Rabbit的几种工作模式介绍与实践 )我们知道,如果要保证消息的可靠性,需要对消息进行持久化处理,然而消息持久化除了需要代码的设置之外,还有一个重要步骤是至关重要的,那就是保证你的消息顺利进入Broker(代理服务器),如图所示: 正常情况下,如果消息经过交换器进入队列就可以完成消息的持久化,但如果消息在没有到达broker之前出现意外,那就造成消息丢失,有没有办法可以解决这个问题? RabbitMQ有两种方式来解决这个问题: 通过AMQP提供的事务机制实现; 使用发送者确认模式实现; 一、事务使用 事务的实现主要是对信道(Channel)的设置,主要的方法有三个: channel.txSelect()声明启动事务模式; channel.txComment()提交事务; channel.txRollback()回滚事务; 从上面的可以看出事务都是以tx开头的,tx应该是transaction extend(事务扩展模块)的缩写,如果有准确的解释欢迎在博客下留言。 我们来看具体的代码实现: // 创建连接 ConnectionFactory factory = new ConnectionFactory();

Confirm deletion using Bootstrap 3 modal box

主宰稳场 提交于 2019-11-26 18:53:51
问题 I need to confirm deletion using Bootstrap 3 modal box (YES/NO). How can I create this? HTML code: <form action="blah" method="POST"> <button class='btn' type="submit" name="remove_levels" value="delete"> <span class="fa fa-times"></span> Delete </button> </form> 回答1: You need the modal in your HTML. When the delete button is clicked it popup the modal. It's also important to prevent the click of that button from submitting the form. When the confirmation is clicked the form will submit. $(

onbeforeunload confirmation screen customization

梦想的初衷 提交于 2019-11-26 14:52:31
问题 Is it possible to create a custom confirmation box for the onbeforeunload event in a browser? I tried but then I get 2 confirmation boxes (one from me which is nothing more than return confirm... and then the standard one from the browser). At the moment my code looks like: var inputChanged = false; $(window).load(function() { window.onbeforeunload = navigateAway; $(':input').bind('change', function() { inputChanged = true; }); }); function navigateAway(){ if(inputChanged){ return 'Are you

How to style default confirm box with only css?

情到浓时终转凉″ 提交于 2019-11-26 14:43:03
I would like to style standard window.confirm without using any additional JavaScript code, only with CSS. Is it even possible? And if it is, how can I do it? solendil It is not possible. This window is displayed by the browser using the platform's UI kit. It's not in the DOM, not visible from the CSS or Javascript, there's nothing you can do. However, some very simple jQuery code can do the trick. How about $('a').confirm(); ? confirm(); alerts cannot be styled, they are generic to the browser. If you want to style an alert, try alternatives such as boxy , or the jQuery dialog box . Here is a

面试五:消息中间件

孤人 提交于 2019-11-26 13:22:53
1…消息中间件?消息中间件特点、应用场景? 异步处理,用户注 解耦,用户下单. 流量削峰,秒杀活动 日志处理 (kafka) 消息通讯,点对点,聊天室 缺点: 系统可用性降低(MQ挂了、MQ高可用性) 系统复杂度提高(重复消费、消息丢失) 数据一致性(B、C成功,D失败) 2.MQ挂了、MQ高可用性怎么解决? RabbitMq的高可用性,基于主从分离 RabbitMq有三种模式: 单机模式 普通集群模式(无高可用性) 互相拉取,做本地持久化,可以提高吞吐量 镜像集群模式(高可用性) 每个MQ都有完整的镜像,太消耗资源 3.重复消费问题?如何保证消息消费的幂等性? 比如你拿个数据要写库,你先根据主键查一下,如果这数据都有了,你就别插入了,update 一下好吧。 比如你是写 Redis,那没问题了,反正每次都是 set,天然幂等性。 比如你不是上面两个场景,那做的稍微复杂一点,你需要让生产者发送每条数据的时候,里面加一个全局唯一的 id,类似订单 id之类的东西,然后你这里消费到了之后,先根据这个 id 去比如 Redis 里查一下,之前消费过吗?如果没有消费过,你就处理,然后这个id 写 Redis。如果消费过了,那你就别处理了,保证别重复处理相同的消息即可。 比如基于数据库的唯一键来保证重复数据不会重复插入多条。因为有唯一键约束了,重复数据插入只会报错,不会导致数据库中出现脏数据

Javascript Confirm popup Yes, No button instead of OK and Cancel

我的梦境 提交于 2019-11-26 10:29:30
Javascript Confirm popup, I want to show Yes, No button instead of OK and Cancel. I have used this vbscript code: <script language="javascript"> function window.confirm(str) { execScript('n = msgbox("' + str + '","4132")', "vbscript"); return (n == 6); } </script> this only works in IE, In FF and Chrome, it doesn't work. Is there any workround to achieve this in Javascript? I also want to change the title of popup like in IE 'Windows Internet Explorer' is shown, I want to show here my own application name. Unfortunately, there is no cross-browser support for opening a confirmation dialog that

How to style default confirm box with only css?

淺唱寂寞╮ 提交于 2019-11-26 04:00:51
问题 I would like to style standard window.confirm without using any additional JavaScript code, only with CSS. Is it even possible? And if it is, how can I do it? 回答1: It is not possible. This window is displayed by the browser using the platform's UI kit. It's not in the DOM, not visible from the CSS or Javascript, there's nothing you can do. However, some very simple jQuery code can do the trick. How about $('a').confirm(); ? 回答2: confirm(); alerts cannot be styled, they are generic to the

How to show the “Are you sure you want to navigate away from this page?” when changes committed?

﹥>﹥吖頭↗ 提交于 2019-11-26 03:13:14
问题 Here in stackoverflow, if you started to make changes then you attempt to navigate away from the page, a javascript confirm button shows up and asks: \"Are you sure you want to navigate away from this page?\" blee blah bloo... Has anyone implemented this before, how do I track that changes were committed? I believe I could do this myself, I am trying to learn the good practices from you the experts. I tried the following but still doesn\'t work: <html> <body> <p>Close the page to trigger the