模态只打开两次

时间:2016-02-23 18:32:45

标签: javascript jquery html jquery-ui

嗨我有问题,我创建的两个模态只打开两次,然后页面崩溃。有谁知道我的代码需要改变什么?

我刚刚发布了整个代码,以确保没有遗漏任何遗憾。

<script type="text/javascript">
$(document).ready(function(){

// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered

var text ="kndsknjdsknjdsnk"


var obj = text;
var title_array = [];
var content_array = [];
for(var i = 0;  i < obj.features.length; i++) {
var featureTitle = obj.features[i].properties.title;
var featureHab = obj.features[i].properties.Broad_Habi;
var timestamp = obj.features[i].properties.timestamp;
var id = obj.features[i].properties.id;
var coordinatesx = obj.features[i].properties.geom_X;
var coordinatesy = obj.features[i].properties.geom_Y;
var image = obj.features[i].properties.Image;
var pos_Acc = obj.features[i].properties.pos_acc;
var name = obj.features[i].properties.Name;
var height = obj.features[i].properties.Approx_Hei;
var evidenve_o = obj.features[i].properties.Evidence_o;
var evidence_f = obj.features[i].properties.Distance_f;
var riverBank = obj.features[i].properties.River_Bank;
var temperature = obj.features[i].properties.Describe_T;
var weather = obj.features[i].properties.Describe_W;
var fieldComm = obj.features[i].properties.Field_Comm;
var MAkeandM = obj.features[i].properties.Make_and_M;
var azimuth = obj.features[i].properties.Azimuth;
var editor = obj.features[i].properties.editor;
var pitch = obj.features[i].properties.Pitch;
var version = obj.features[i].properties.OS_Version;
var roll = obj.features[i].properties.Roll;




$('#myTableData tbody').append(
'<tr><td><a class="btn-floating btn-smal waves-effect waves-light"><i id="'+id+'" data-target="modal1" class="btn-floating modal-trigger small material-icons">info_outline</i></a></td>'+
    '<td><a class="btn-floating btn-smal waves-effect waves-light"><i class="btn-floating small material-icons" onClick="Javacsript:deleteRow(this)">delete</i></a></td>'+
    '<td><img src ="' + image + '"class="responsive-img"></td>'+
                                '<td>'+featureTitle+'</td>'+
                                '<td>'+name+'</td>'+
                                '<td>'+timestamp+'</td>'+
                                '<td>'+coordinatesx+'</td>'+
                                '<td>'+coordinatesy+'</td>'+
                                '</tr>');

title_array[id] = featureTitle;
content_array[id] = 'id:   '+id+'<br />'+'title:   '+featureTitle+'<br />'+'Name:   '+name+'<br />'+'timestamp:   '+timestamp+'<br />'+'coordinatesx:   '+coordinatesx+'<br />'+'coordinatesy:   '+coordinatesy+'<br />'+'pos_Acc:   '+pos_Acc+'<br />'+'height:   '+height+'<br />'+'evidenve_o:   '+evidenve_o+'<br />'+'evidence_f:   '+evidence_f+'<br />'+'riverBank:   '+riverBank+'<br />'+'temperature:   '+temperature+'<br />'+'weather:   '+weather+'<br />'+'fieldComm:   '+fieldComm+'<br />'+'MAkeandM:   '+MAkeandM+'<br />'+'azimuth:   '+azimuth+'<br />'+'editor:   '+editor+'<br />'+'pitch:   '+pitch+'<br />'+'version:   '+version+'<br />'+'roll:   '+roll+'<br /><td><img src ="' + image + '"class="responsive-img"></td>';

}
$('.modal-trigger').click(function() {

  $('#modal1').openModal();
        $(".modal_title").text(title_array[$(this).attr('id')]);
        $(".modal_text").html(content_array[$(this).attr('id')]);
        $(this).leanModal();
    });

$('.modal-trigger1').click(function() {

  $('#bottommodal1').openModal();
  $(this).leanModal();
});

$('.modal-triggerclose').click(function() {

  $('#modal1').closeModal();
});


});</script>

1 个答案:

答案 0 :(得分:0)

感谢您的帮助。

我发现了我的错误

$(本).leanModal();导致错误,因为我打开它两次,所以没有它,它工作正常。

$('.modal-trigger1').click(function() {
$('#bottommodal1').openModal();
});