1

在灯箱中使用 JavaScript 时遇到问题:我已经为我的网站实现了评级功能。当我在普通的嵌入式 html 中使用该功能时,效果很好,但用户会被带到反馈页面。我想使用灯箱来提供反馈,让用户有可能提供反馈并留在他实际所在的位置。

现状:一切正常,但 JS 脚本未在灯箱中启动。表示评级的单选按钮不会被带有星形图像的脚本替换。最后我收到这个错误:

TypeError: starRating is undefined starRating.create('.feedbackSelect');

当我从 Firebug 中复制错误时,我收到以下信息:

TypeError:starRating 未定义 http://xxx.xxx.xxx.xxx/xxxx/interface/themes/blueprint/js/jquery.min.js/eval/seq/2第2行

var starRating 在后面的行中定义:

var starRating = {
  create: function(selector) {
...

让我感到困惑的是,Firebug 指的是另一个文件,即 jQuery 库,并且再次:没有灯箱它可以正常工作。我会感谢任何提示如何解决这个问题!

pd:这里是 smarty 的 html 代码:

{js filename="feedback.js"}

{* <div class="span-5 {if $sidebarOnLeft}pull-18 sidebarOnLeft{else}last{/if}">
  {include file="MyResearch/menu.tpl"}
</div> *}

<div class="span-18{if $sidebarOnLeft} push-5 last{/if}">
  {if $user->cat_username}
    <h1>{translate text='Feedback'}</h1>
    <br>
    {if $success}
      <p class="success">{translate text='feedback_thanks'}</p>
    {else}
      {if $errorMsg}
        <p class="error">{translate text=$errorMsg}</p>
      {/if}
      <form method="post" action="{$url}/Feedback/Feedback" id="feedback_form">
        <input type="hidden" name="hash" value="{$hash|escape}" />
        <table id="feedback" class="citation">
        {if $feedbackIssues}

          {foreach from=$feedbackIssues item=issue}


        <tr>
          <th>{translate text=$issue->title}:</th>
          <td class="feedbackSelect">
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-1"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-1" name="issue{$issue->id|escape}" type="radio" value="1"/>0.5</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-2"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-2" name="issue{$issue->id|escape}" type="radio" value="2"/>1</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-3"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-3" name="issue{$issue->id|escape}" type="radio" value="3"/>1.5</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-4"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-4" name="issue{$issue->id|escape}" type="radio" value="4"/>2</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-5"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-5" name="issue{$issue->id|escape}" type="radio" value="5"/>2.5</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-6"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-6" name="issue{$issue->id|escape}" type="radio" value="6"/>3</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-7"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-7" name="issue{$issue->id|escape}" type="radio" value="7"/>3.5</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-8"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-8" name="issue{$issue->id|escape}" type="radio" value="8"/>4</label>
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-9"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-9" name="issue{$issue->id|escape}" type="radio" value="9"/>4.5</label> 
            <label for="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-10"><input id="{$issue->title|lower|regex_replace:'/[^a-z0-9]/':''|escape}-10" name="issue{$issue->id|escape}" type="radio" value="10"/>5</label>  
          </td>
        </tr>
        {/foreach}
        {/if}

        <tr>
          <th>{translate text="Comments"}:</th>
          <td><textarea name="comment" class="formularLarge">{$comment}</textarea></td>
        </tr>

        <tr>
          <th>&nbsp;</th>
          <td><input type="submit" name="submitFeedback" value="{translate text="submit_feedback"}" class="senden"></td>
        </tr>

        </table>
      </form>
    {/if}
  {else}
    {include file="AJAX/login.tpl"}
  {/if}
</div>


<div class="clear"></div>
4

0 回答 0