脚本不会显示在页面中

时间:2017-05-04 22:57:59

标签: javascript php jquery

我试过了,但它没有在页面内显示。问题在哪里?

      $content ='
                <div class="row">
                  <div class="col-md-9">
                    <div class="form-group row">
                      <label for="' . $this->app->getDef('text_products_favorites') . '" class="col-5 col-form-label">' . $this->app->getDef('text_products_favorites') . '</label>
                      <div class="col-md-5">
                        ' . HTML::checkboxField('products_favorites', 'yes', false) . '
                      </div>
                    </div>
                  </div>
                </div>      
      ';


      $output = <<<EOD
<script>
$('#tab9Content').prepend(
    '{$content}'
)
</script>
EOD;
        return $output;

如果我按此更改脚本,它可以正常工作并且信息显示在页面

$('#tab9Content').prepend(
    '<h3>Brown</h3>' + 
    '<p>Brown Brown Brown</p>'
)

现在在products.php

 <div class="adminformTitle" id="tab9Content">
</div>

如果我编辑mycode,我就有了。

<div class="adminformTitle" id="tab9Content">
<script>
$('#tab9Content').prepend(
    '
                <div class="row">
                  <div class="col-md-9">
                    <div class="form-group row">
                      <label for="text_products_favorites" class="col-5 col-form-label">text_products_favorites</label>
                      <div class="col-md-5">
                        <input type="checkbox" name="products_favorite" id="products_favorite" value="yes" />
                      </div>
                    </div>
                  </div>
                </div>      
      '
)
</script>
</div>

1 个答案:

答案 0 :(得分:0)

我找到了这个改变的解决方案:

# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
class UserMailerPreview < ActionMailer::Preview

    def confirmation_instructions
        @user = User.last
        @getUser = User.find(@user)
        @token = @getUser.confirmation_token
        Devise::Mailer.confirmation_instructions(@user, @token)
    end

    def reset_password_instructions
        @user = User.last
        @getUser = User.find(@user)
        @token = @getUser.reset_password_token
        Devise::Mailer.reset_password_instructions(@user,@token)
      end
end