2014-02-28 62 views
0

我有一个模态窗口,里面有一个选择。 模式工作正常,但选择只能使用一次。 问题是什么?jquery模式选择问题

这是我的js。

$s = jQuery.noConflict(); 
$s(document).ready(function() { 

//Display the modal 
$s('#att-add').on('click', function (e) { 
    e.preventDefault(); 
    $s.fn.custombox(this, { 
     overlay: true, 
     effect: 'fadein', 
     eClose: '.close' 
    }); 
    $s('select').selectric(); 
}); 
}); 

对于我使用Selectric的选择框。

这是我的HTML模态窗口

<div id="modal" style="display: none;" class="modal-content"> 
    <div class="modal-header"> 
     <button type="button" class="close" title="inchide">&times;</button> 
     <h3>Adauga un atribut nou</h3> 
    </div> 
    <div class="modal-body"> 
     <div class="form-group"> 
     <label>Numele atributului</label> 
     <input type="text" name="name" atocomplete="off" /> 
     </div> 
     <div class="form-group"> 
     <label>Selectati grupul de atribute</label> 
     <select name="groups" class="select"> 
      {section name=op loop=$groups.attribute_group_id} 
      <option value="{$groups.attribute_group_id[op]}">{$groups.name[op]}</option> 
      {/section} 
     </select> 
     </div> 
     <div class="form-group"> 
     <label>Ordinea</label> 
     <input class="ordine" type="text" name="ordine"/> 
     </div> 
    </div> 
</div> 
+0

当你说“只选择一次作品”时,你的意思是selectric只在第一次打开模式时才应用?那么当你关闭模式并再次打开它时,它不会被应用?你是否在控制台中发现错误?你能包含你的HTML吗? –

+0

我已经包含它 – ciprian2301

+0

您使用模板吗?问题是模板不起作用,或者电气造型没有被应用? –

回答

0

我认为问题是,当selectric适用它的造型,它消除了select元素和里面的模板。你可能需要做的是传递一个回调的customboxclose财产破坏selectric当用户关闭模式:

$s = jQuery.noConflict(); 
$s(document).ready(function() { 

    //Display the modal 
    $s('#att-add').on('click', function (e) { 
     e.preventDefault(); 
     $s.fn.custombox(this, { 
      overlay: true, 
      effect: 'fadein', 
      eClose: '.close', 
      close: function() { $s('select').selectric('destroy'); } 
     }); 
     $s('select').selectric(); 
    }); 
}); 

这是未经测试,我无法轻松地重现该问题。

+0

是的,这很好,它的工作 – ciprian2301

1

我不熟悉的Selectric但我猜有可能是因为你是初始化同样选择的每次点击。尝试在点击功能之外移动$s('select').selectric();行。

$s = jQuery.noConflict(); 
    $s(document).ready(function() { 

    $s('select').selectric(); 

    //Display the modal 
    $s('#att-add').on('click', function (e) { 
     e.preventDefault(); 
     $s.fn.custombox(this, { 
      overlay: true, 
      effect: 'fadein', 
      eClose: '.close' 
     }); 
    }); 
    });