{% extends 'horizon/common/_data_table.html' %}
{% load i18n %}

{% block table_columns %}
  {% if not table.is_browser_table %}
  <tr>
    {% for column in columns %}
        <th {{ column.attr_string|safe }}><span
            {% if column.name in table.get_required_columns %}
                class="required"
            {% endif %}
        >{{ column }}</span></th>
    {% endfor %}
  </tr>
  {% endif %}
{% endblock table_columns %}

{% block table %}
    {% with table.get_formset as formset %}
        {{ formset.management_form }}
        {% if formset.non_field_errors %}
            <div class="alert alert-error">
                {{ formset.non_field_errors }}
            </div>
        {% endif %}
    {% endwith %}
    {{ block.super }}

<script type="text/javascript">
    ($ || addHorizonLoadEvent)(function () {
        // prepare the js-enabled parts of the formset data table
        var prefix = '{{ table.name|escapejs }}';
        var empty_row_html = '{% filter escapejs %}{% include "formset_table/_row.html" with row=table.get_empty_row %}{% endfilter %}';
        {% if table.formset_class.extra %}
        var add_label = '{% filter escapejs %}{% trans "Add a row" %}{% endfilter %}';
        {% else %}
        var add_label = '';
        {% endif %}

        tuskar.formset_table.init(prefix, empty_row_html, add_label);
    });
</script>
{% endblock table %}

{% extends 'horizon/common/_data_table.html' %}
{% load i18n %}

{% block table_columns %}
  {% if not table.is_browser_table %}
  <tr>
    {% for column in columns %}
        <th {{ column.attr_string|safe }}><span
            {% if column.name in table.get_required_columns %}
                class="required"
            {% endif %}
        >{{ column }}</span></th>
    {% endfor %}
  </tr>
  {% endif %}
{% endblock table_columns %}

{% block table %}
    {% with table.get_formset as formset %}
        {{ formset.management_form }}
        {% if formset.non_field_errors %}
            <div class="alert alert-error">
                {{ formset.non_field_errors }}
            </div>
        {% endif %}
    {% endwith %}
    {{ block.super }}

<script type="text/javascript">
    (window.$ || window.addHorizonLoadEvent)(function () {
        // prepare the js-enabled parts of the formset data table
        var prefix = '{{ table.name|escapejs }}';
        var empty_row_html = '{% filter escapejs %}{% include "formset_table/_row.html" with row=table.get_empty_row %}{% endfilter %}';
        {% if table.formset_class.extra %}
        var add_label = '{% filter escapejs %}{% trans "Add a row" %}{% endfilter %}';
        {% else %}
        var add_label = '';
        {% endif %}

        tuskar.formset_table.init(prefix, empty_row_html, add_label);
    });
</script>
{% endblock table %}

Fix JS warnings when $ is not available
Fix JS warnings when $ is not available

The construction ($ || addHorizonLoadEvent) complains when $ is not
defined. Using (window.$ || window.addHorizonLoadEvent) instead solves
this problem.

Change-Id: Ied5db7398f6ca1d25906c84d5e40a4bae6c01f39
