OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

UIKit, How to disable toggle item close itself when toggle item clicked by javascript control

  • Thread starter Thread starter jimmy123j
  • Start date Start date
J

jimmy123j

Guest
I want to use the UIKit toggle the table's by javascript

work find, but click toggle item will close itself

I don't want the toggle target close itself when it's clicked, only toggle link or button control the toggle open and close

Codpen Sample

Code:
<!doctype html>

<html>

    <body>

        <div id="Test_Table_Div">

            <table id="Test_Table">

                <tr class="A">

                    <td>
                         <a>Link_Click_Toggle</a>
                    </td>

                </tr>

                <tr class="B" hidden>

                    <td>
                        <table> 
                            <tr><td>123</td></tr> 
                            <tr><td>ABC</td></tr> 
                        </table> 
                    </td>

                </tr>

            </table>

        </div>

    </body>

<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit.min.js"></script>

</html>

Code:
$("#Test_Table_Div").on( "click", "#Test_Table tr.A a",  function() {

  UIkit.toggle("#Test_Table_Div #Test_Table tr.B", {  animation: "uk-animation-fade" }).toggle() ;

}) ;

<p>I want to use the UIKit toggle the table's by javascript</p>
<p>work find, but click toggle item will close itself</p>
<p>I don't want the toggle target close itself when it's clicked, only toggle link or button control the toggle open and close</p>
<p><a href="https://codepen.io/jimmy123j/pen/xxNpZLX" rel="nofollow noreferrer">Codpen Sample</a></p>
<pre><code><!doctype html>

<html>

<body>

<div id="Test_Table_Div">

<table id="Test_Table">

<tr class="A">

<td>
<a>Link_Click_Toggle</a>
</td>

</tr>

<tr class="B" hidden>

<td>
<table>
<tr><td>123</td></tr>
<tr><td>ABC</td></tr>
</table>
</td>

</tr>

</table>

</div>

</body>

<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/uikit.min.js"></script>

</html>

</code></pre>
<pre><code>
$("#Test_Table_Div").on( "click", "#Test_Table tr.A a", function() {

UIkit.toggle("#Test_Table_Div #Test_Table tr.B", { animation: "uk-animation-fade" }).toggle() ;

}) ;

</code></pre>
 

Latest posts

Top