显示不带触发器的弹出框

时间:2015-10-29 10:40:04

标签: jquery twitter-bootstrap-3 popover

我想显示一个没有任何触发器选项的弹出窗口..我试过这个但它不起作用..

$('#boo').popover({
    placement : 'right',
    html : true,
    trigger : 'show', 
    content: "write sth"
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="boo" type="submit" class="btn btn-default">go</button>

[更新] 我只是注意到触发器选项中没有列出show ..(link)..有没有办法让它工作?

1 个答案:

答案 0 :(得分:0)

您只需拨打import java.awt.EventQueue; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class TestLayout { public static void main(String[] args) { new TestLayout(); } public TestLayout() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class TestPane extends JPanel { public TestPane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(8, 8, 2, 8); add(new JLabel(new ImageIcon(getClass().getResource("/gender_neutral_user.png"))), gbc); gbc.gridx++; gbc.insets = new Insets(8, 2, 4, 8); gbc.fill = GridBagConstraints.HORIZONTAL; add(new JTextField(10), gbc); JList list = new JList(); list.setVisibleRowCount(10); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridx = 0; gbc.gridy++; gbc.insets = new Insets(4, 8, 8, 8); gbc.fill = GridBagConstraints.BOTH; add(new JScrollPane(list), gbc); } } } 方法

即可

show
$('#boo').popover({
    placement : 'right',
    html : true,
    trigger : 'show', 
    content: "write sth"
});

$('#boo').popover('show')