1

Ok so it sounds confusing... but in essence what im trying to do should make sense.

I am using jquery tabs. In these tabs I have some lists and some form fields.

so...

Tab a = list a with some form fields... Tab b = list b with formfields... and so on.

BUT... one of these tabs is an ALL tab. and it contains ListA and List B etc etc.

So my question is this.

If a user updates TAB A (list A) How can I get TAB C (all lists) to update with the same value?

Hope that makes sense.

Thanks in advance W

4

1 に答える 1

2

以下は、1 つの入力を含むタブと、それらすべてを含むタブの例です。いずれかの入力への変更は、自動的に (イベントで) コピーに送信されます ([すべて] タブ ( demokeyup )で変更を行った場合でも):

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Nunc tincidunt</a>
        </li>
        <li><a href="#tabs-2">Proin dolor</a>
        </li>
        <li><a href="#tabs-3">Aenean lacinia</a>
        </li>
        <li><a href="#tabs-4">All</a>
        </li>
    </ul>
    <div id="tabs-1">
        <p>
            A:<input name='A' />
        </p>
    </div>
    <div id="tabs-2">
        <p>
            B:<input name='B' />
        </p>
    </div>
    <div id="tabs-3">
        <p>
            C:<input name='C' />
        </p>
    </div>
    <div id="tabs-4">
        <p>
            A:<input name='A' /><br/>
            B:<input name='B' /><br/>
            C:<input name='C' /><br/>
        </p>
    </div>
</div>
<script>
$(function () {
    $("#tabs").tabs();
    $('input[name=A],input[name=B],input[name=C]').on('keyup change', function() {
        $('input[name='+$(this).attr('name')+']').val($(this).val());
    })
});
</script>
于 2013-10-24T17:04:46.170 に答える