从外部文件显示模式

时间:2019-06-18 15:51:09

标签: javascript jquery bootstrap-4 bootstrap-modal

我的网站上有一些引导程序模式,这些模式通过“图像”按钮调用。我只想简单地查找主文件,所以我希望从外部文件调用模态数据。但是它没有按我预期的那样工作。代码的第一段是我调用模式的原始代码。第二部分是分配了ID和类的新代码。最后一部分是我的加载功能。感谢您的帮助!

我尝试使用js加载功能从外部文件加载模态数据,但是当我单击图像时它没有任何作用。

**Original Code**
<div class="col-md-2 col-4"> \\Original Code to invoke modal
<button type="button" class="playerbutton" data-toggle="modal" data- 
target="#three"><img src="images\123.png" class="squadplayerimg"> 
</button>
<!--  player Modal -->
<div class="modal fade" id="three" tabindex="-1" role="dialog" aria- 
labelledby="three" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
  <div class="modal-header">
    <h5 class="modal-title">Player Info</h5>
    Main modal body and data ........
  </div>

**New Code**
 <div class="col-md-2 col-4">
 <button type="button" class="playerbutton test"><img 
 src="images\123.png" class="squadplayerimg"></button>
 <div id="three" class="modal fade text-center">
 <div class="modal-dialog">
  <div class="modal-content">
  Get data from outside files
  </div>
  </div>
  </div>

 </div>

**js load function**
$('test').load("newmodal.html #three",function(){
$('#three').modal();
});

1 个答案:

答案 0 :(得分:1)

您可以尝试以下操作: 可以根据自己的喜好随意更改。

import tensorflow as tf
import numpy as np
import os

"""Build data and label arrays to feed neural network"""
dataList = []
for filename in os.listdir("data"): #reading in some file name date
    dataList.append(np.load("data\\" + filename))
data = np.array(dataList) 
#creating arrays
labelsList = []
wavelengthList = []
thetaList = []
phiList = []
ampList = []
for filename in os.listdir("labels"):
    labelsList.append(np.load("labels\\" + filename))
for subList in labelsList:
    wavelengthList.append(subList[0])
    thetaList.append(subList[1])
    C.append(subList[2])
    ampList.append(subList[3])
wavelengthArray = np.array(wavelengthList)
thetaArray = np.array(thetaList)
phiArray = np.array(phiList)
ampArray = np.array(ampList)

"""Train neural network"""
inputLayer = tf.keras.layers.Input(shape=(33,33))
flatInput = tf.keras.layers.Flatten()(inputLayer) #ensure that image is flat

x = tf.keras.layers.Dense(64, activation='relu')(flatInput)
x = tf.keras.layers.Dense(64, activation='relu')(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)

wavelengthLayer = tf.keras.layers.Dense(1, activation='linear')(x)
thetaLayer = tf.keras.layers.Dense(1, activation='linear')(x)
phiLayer = tf.keras.layers.Dense(1, activation='linear')(x)
ampLayer = tf.keras.layers.Dense(1, activation='linear')(x)

model = tf.keras.models.Model(inputs=inputLayer, outputs=[wavelengthLayer,
    thetaLayer, phiLayer, ampLayer])

model.compile(optimizer='rmsprop', loss='mse')
model.fit(data, [wavelengthArray, thetaArray, phiArray, ampArray], epochs=100) #trains model

model.save("Wave Model.model")
$("#somediv").click(function() {
  opendialog("http://jsbooks.revolunet.com/");
});

function opendialog(page) {
  var $dialog = $('#somediv')
  .html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
  .dialog({
    title: "Page",
    autoOpen: false,
    dialogClass: 'dialog_fixed,ui-widget-header',
    modal: true,
    height: 500,
    minWidth: 400,
    minHeight: 400,
    draggable:true,
    /*close: function () { $(this).remove(); },*/
    buttons: { "Ok": function () {         $(this).dialog("close"); } }
  });
  $dialog.dialog('open');
}