{"id":374,"date":"2016-11-21T09:30:19","date_gmt":"2016-11-21T01:30:19","guid":{"rendered":"http:\/\/loveuhouse.cn\/wordpress\/?p=374"},"modified":"2016-11-21T09:30:19","modified_gmt":"2016-11-21T01:30:19","slug":"bootstrap-js%e5%88%9b%e5%bb%ba%e6%a8%a1%e6%80%81%e6%a1%86","status":"publish","type":"post","link":"https:\/\/loveuhouse.cn\/wordpress\/?p=374","title":{"rendered":"bootstrap js\u521b\u5efa\u6a21\u6001\u6846"},"content":{"rendered":"<p>Modal \u5c5e\u6027<\/p>\n<p>**m_\u7cfb\u5217\u2014\u2014\u6587\u5b57\u63cf\u8ff0\u3001\u5185\u5bb9\u7c7b<\/p>\n<p>\/\/\u6a21\u6001\u6846\u62ac\u5934\u6807\u9898<\/p>\n<p>Modal.m_title=\"string\";<\/p>\n<p>\/\/\u6a21\u6001\u6846\u5185\u5bb9\u533a\u57df<\/p>\n<p>Modal.m_body=\"string\";\/\/\u652f\u6301html\u5bf9\u8c61<\/p>\n<p>\/\/\u6a21\u6001\u6846id<\/p>\n<p>Modal.m_id=\"string\";<\/p>\n<p>**set_\u7cfb\u5217\u2014\u2014\u6267\u884c\u51fd\u6570\u7c7b<\/p>\n<p>\/\/\u751f\u6210\u6a21\u6001\u6846\u5e95\u90e8\u6309\u94ae<\/p>\n<p>Modal.set_btn({\"string\":callback})\/\/\u6309\u94ae\u6587\u5b57\u3001\u6267\u884c\u51fd\u6570<\/p>\n<p>**\u57fa\u7840\u7cfb\u5217<\/p>\n<p>\/\/\u5f39\u51fa\u6a21\u6001\u6846<\/p>\n<p>Modal.create()<\/p>\n<p>\/\/\u5173\u95ed\u6a21\u6001\u6846<\/p>\n<p>Modal.close()<\/p>\n<pre class=\"lang:js decode:true \">\/\/\u6a21\u6001\u6846\nfunction CreateModal(){\n  this.m_title=\"\u9ed8\u8ba4\u6a21\u6001\u6846\";\n  this.m_body=\"\u9ed8\u8ba4\u5185\u5bb9\";\n  this.m_id=\"newmodal\";\n  this.m_target=\"body\";\n  this.btn=[];\n  this.set_btn=function(data){\n    var btnarr=[];\n    for(var key in data){\n      var btn = document.createElement(\"button\");\n      btn.className=\"btn btn-primary\";\n      btn.onclick=data[key];\n      btn.innerHTML=key;\n      this.btn.push(btn);\n    }\n  }\n  this.close=function(){\n    $(\".modal.fade\").remove();\n    $(\".modal-backdrop.fade\").remove();\n  }\n  this.create=function(){\n    this.close();\n    var modal_block = document.createElement(\"div\");\n      modal_block.className = \"modal fade\";\n      modal_block.id = this.m_id;\n      modal_block.setAttribute(\"data-show\",\"true\")\n      var modal_dialog = document.createElement(\"div\");\n        modal_dialog.className=\"modal-dialog modal-lg\";\n        var modal_content = document.createElement(\"div\");\n          modal_content.className=\"modal-content\";\n          var modal_head = document.createElement(\"div\");\n            modal_head.className=  \"modal-header\";\n            var btn_close = document.createElement(\"button\");\n              btn_close.className=\"close\";\n              btn_close.type=\"button\";\n              btn_close.innerHTML=\"&amp;times;\";\n              btn_close.addEventListener(\"click\",this.close);\n            modal_head.appendChild(btn_close);\n            var modal_head_p = document.createElement(\"h4\");\n              modal_head_p.innerHTML=this.m_title;\n            modal_head.appendChild(modal_head_p);\n          modal_content.appendChild(modal_head);\n          var modal_body = document.createElement(\"div\");\n            modal_body.className=\"modal_body\";\n            if(typeof(this.m_body)==\"string\"){\n              modal_body.innerHTML=this.m_body;\n            }else{\n              modal_body.appendChild(this.m_body);\n            }\n          modal_content.appendChild(modal_body);\n          var modal_footer =document.createElement(\"div\");\n            modal_footer.className=\"modal-footer\";\n            this.btn.map(function(btns,index){\n              modal_footer.appendChild(btns);\n            })\n          modal_content.appendChild(modal_footer);\n        modal_dialog.appendChild(modal_content);\n      modal_block.appendChild(modal_dialog);\n\n    $(this.m_target).append(modal_block);\n    $(\"#\"+this.m_id).modal('show');\n  }\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Modal \u5c5e\u6027 **m_\u7cfb\u5217\u2014\u2014\u6587\u5b57\u63cf\u8ff0\u3001\u5185\u5bb9\u7c7b \/\/\u6a21\u6001\u6846\u62ac\u5934\u6807\u9898 Modal.m_title=&#8221;stri &hellip; <a href=\"https:\/\/loveuhouse.cn\/wordpress\/?p=374\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">bootstrap js\u521b\u5efa\u6a21\u6001\u6846<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/374"}],"collection":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=374"}],"version-history":[{"count":1,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":375,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/374\/revisions\/375"}],"wp:attachment":[{"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loveuhouse.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}