【问题标题】:jQuery slider plugin values not working when fetching from database?从数据库中获取时,jQuery 滑块插件值不起作用?
【发布时间】:2013-05-31 11:10:50
【问题描述】:

我正在 Prestashop 中做一个模块。我已将fancytransection 作为滑块。在根据文档的滑块中,我使用所有这些值来显示滑块

effect: '', // wave, zipper, curtain
width: 500, // width of panel
height: 332, // height of panel
strips: 20, // number of strips
delay: 5000, // delay between images in ms
stripDelay: 50, // delay beetwen strips in ms
titleOpacity: 0.7, // opacity of title
titleSpeed: 1000, // speed of title appereance in ms
position: 'alternate', // top, bottom, alternate, curtain
direction: 'fountainAlternate', // left, right, alternate, random, fountain, fountainAlternate
navigation: false, // prev and next navigation buttons
links: false // show images as links

这里我从数据库中获取width,height and navigation 的值。这样就可以手动为所有这些设置值。 这适用于我从数据库中获取的宽度和高度。但是我从数据库中得到的导航值是真还是假都不起作用。每次它显示滑块导航。

这是我的 .tpl 文件中使用的代码

<script>
 var result_navigation="{$result_navigation}";
 var result_width="{$result_width}";
 var result_height="{$result_height}";
 $.fn.jqFancyTransitions.defaults = {  
      width: result_width, // width of panel
      height: result_height, // height of panel
      strips: 10, // number of strips
      delay: 5000, // delay between images in ms
      stripDelay: 50, // delay beetwen strips in ms
      titleOpacity: 0.7, // opacity of title
      titleSpeed: 1000, // speed of title appereance in ms
      position: 'alternate', // top, bottom, alternate, curtain
      direction: 'fountainAlternate', // left, right, alternate, random, fountain, fountainAlternate
      effect: '', // curtain, zipper, wave
      navigation: result_navigation, // prev next and buttons
      links : true // show images as links     
    };
 </script>

这里作为 result_width 的宽度和作为 result_height 的高度的值工作正常。但是使用false or true value,result_navigation 的值很好。但是当我在代码中使用它时它不起作用。它显示导航就像值是真的一样。 false 的值在这里不起作用。有人可以告诉我如何解决这个问题吗?任何帮助和建议都将非常可观。谢谢

【问题讨论】:

    标签: php jquery jquery-plugins module prestashop


    【解决方案1】:

    检查{$result_navigation} 的输出。当您使用引号时,您正在传递一个字符串,这将在 js 代码中被视为真实的。你应该尝试这样的事情:

    <script>
        // if you use a boolean
        var result_navigation = {if $result_navigation}true{else}false{/if};
    
        // if you use `true` or `false` as strings - but that's just weird
        var result_navigation = {if $results_navigation == 'true'}true{else}false{/if};
    
    </script>
    

    【讨论】:

    • 感谢您的回复。是的,我得到{$result_navigation} 的输出为假或真。但不知道为什么它在这里不起作用。
    • 但是你是输出 false 还是 true 作为字符串还是布尔值?
    • 更新了我的答案。您可以使用 true 或 false 作为字符串,但布尔值是为这些东西制作的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2019-01-24
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多