1

我喜欢这个来自www.listjs.com的脚本 list.js。它似乎非常适合搜索和过滤下面的 php 文件的输出,但我可以让它工作,我只需要添加 7 行左右的代码但它不起作用。谁能告诉我怎么来的?谢谢

我添加的代码突出显示

<?php
defined('_JEXEC') or die();
?>
**<script type="text/javascript" src="list.js"></script>**
<form action="<?php echo CRoute::getURI(); ?>" method="post" id="jomsForm" name="jomsForm" class="community-form-validate">
<div class="jsProfileType" **id="jsProfileType"**>
    **<input class="search" placeholder="Search" />
        <button class="sort" data-sort="label">
            Sort
        </button>**
    <ul class="unstyled">
    <?php
        foreach($profileTypes as $profile)
        {
    ?>
        <li class="space-12">

            <label for="profile-<?php echo $profile->id;?>" class="radio">
                <input id="profile-<?php echo $profile->id;?>" type="radio" value="<?php echo $profile->id;?>" name="profileType" <?php echo $default == $profile->id ? ' disabled CHECKED' :'';?> />
              <strong class="bold"><?php echo $profile->name;?></strong>
            </label>
            <?php if( $profile->approvals ){?>
                <span class="help-block"><?php echo JText::_('COM_COMMUNITY_REQUIRE_APPROVAL');?></span>
            <?php } ?>

            <span class="help-block">
                <?php 
                    $profile->description = JHTML::_('content.prepare',$profile->description);
                    echo $profile->description;?>
            </span>

            <?php if( $default == $profile->id ){?>
                    <em><?php echo JText::_('COM_COMMUNITY_ALREADY_USING_THIS_PROFILE_TYPE');?></em>
            <?php } ?>



        </li>
    <?php
        }
    ?>
    </ul>
</div>
<?php if( (count($profileTypes) == 1 && $profileTypes[0]->id != $default) || count($profileTypes) > 1 ){?>
<div style="margin-top: 5px;">
    <?php if( $showNotice ){ ?>
    <span style="color: red;font-weight:700;"><?php echo JText::_('COM_COMMUNITY_NOTE');?>:</span>
    <span><?php echo $message;?></span>
    <?php } ?>
</div>
**<script>
var options = {
    list: "space-12"
};
var userList = new List('jsProfileType', options);
</script>**
<table class="ccontentTable paramlist" cellspacing="1" cellpadding="0">
  <tbody>
    <tr>
        <td class="paramlist_key" style="text-align:left">
            <div id="cwin-wait" style="display:none;"></div>
            <input class="btn btn-primary validateSubmit" type="submit" id="btnSubmit" value="<?php echo JText::_('COM_COMMUNITY_NEXT'); ?>" name="submit">
        </td>
        <td class="paramlist_value">

        </td>
    </tr>
</tbody>
</table>
<?php } ?>
<input type="hidden" name="id" value="0" />
<input type="hidden" name="gid" value="0" />
<input type="hidden" id="authenticate" name="authenticate" value="0" />
<input type="hidden" id="authkey" name="authkey" value="" />
</form>
4

1 回答 1

3

我不知道 PHP,但是我之前在自己的项目中使用 list.js 时看到过这个错误。事实证明我没有正确定义事物。

您确实设置了div一个正确的 id,但您似乎缺少一个“列表”类。尝试改变

<ul class="unstyled">

<ul class="list">

其次,我不认为 'list' 是选项中受支持的关键字(至少在最新的 list.js 版本中不是)。尝试将您的选项定义更改为

var options = {
    valueNames: [ 'space-12' ]
};

第三,如果你想让搜索工作改变

<button class="sort" data-sort="label">

<button class="sort" data-sort="space-12">
于 2014-01-15T13:33:03.480 回答