我在这个模态弹出窗口中做错了什么

时间:2015-06-25 21:07:00

标签: jquery

需要帮助需要有关模态弹出窗口的帮助。我是新手并且学习。 Pop由于某种原因不起作用。得到错误

  

未捕获TypeError:$(...)。modal不是函数。

我知道我做错了什么。你能否建议以及如何解决

 <!-- popup code start here -->
<div class="modal fade" id="mypop" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        </div>

      <div class="modal-body">
        <h4>We are unable to locate your device.</h4>
        <h4>Please select your country and language.</h4>
        <div class="form-group col-lg-12 col-md-12 col-xs-12 no_padding">
                <div class="no_padding">
            <label>My Country:</label>
            <select name="countries_popup" id="countries_popup" class="selectBox">
            <option selected="selected">Choose country</option>
                <option>United Kingdom</option>

            </select>
            </div>
            </div>
            <br>
            <div class="form-group col-lg-12 col-md-12 col-xs-12 no_padding">
                <div class="no_padding">
            <label>My language:</label>
            <select name="language_popup" id="language_popup" class="selectBox">
            <option selected="selected">Choose language</option>

                <option>United Kingdom</option>

            </select>
            </div>
            </div>

      </div>
      <div class="modal-footer">

        <button type="button" class="btn btn-primary col-xs-12 col-sm-6 gonext">Next</button>
      </div>
    </div>
  </div>
</div>

<!-- popup code end here -->

$(window).load(function(){ 
console.log("popup")
$("#mypop").modal();

});

2 个答案:

答案 0 :(得分:0)

我将你的代码粘贴到通用页面布局中(使用CDNs进行jQuery和bootstrap),一切似乎都有效。在执行与这些库相关的任何功能之前,您必须确保包含jQuery和bootstrap。我通常在页面末尾包含库和脚本,但是你可以将你的启动代码包装在$(document).ready(function(){...})中;如果你愿意的话。

 @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Init view elements
        topTextView = (TextView) findViewById(R.id.textView1);
        counterButton = (Button) findViewById(R.id.button1);

        // Init element events
        counterButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Toast toast = Toast.makeText(getApplicationContext(),
                        "Button was clicked", Toast.LENGTH_LONG);
                toast.show();

                topTextView.setText("Updated from button");
            }
        });
    }

当脚本位于正文内容之后,排除window.load()应该是安全的。

答案 1 :(得分:0)

由于您使用了引导程序,因此需要包含{ "Version":"2012-10-17", "Statement":[ { "Sid":"AddCannedAcl", "Effect":"Allow", "Principal": {"AWS": ["arn:aws:iam::111122223333:root","arn:aws:iam::444455556666:root"]}, "Action":["s3:PutObject","s3:PutObjectAcl"], "Resource":["arn:aws:s3:::examplebucket/*"], "Condition":{"StringEquals":{"s3:x-amz-acl":["public-read"]}} } ] } css文件引用。

在您添加js代码后包含以下内容。

jquery

这是一个有效的JSFIDDLE