0

できるかどうかわからないアイデアについてアドバイスを求めています...

私はデータベースからレコードをロードし、それらを個々の div にリストし、データベースから id 番号を div に追加しています。

jquery である種のプラグインを使用して、レコードをクリックすると右側からタブがスライドし、データベースからの個々のレコードに関するより多くのデータが表示されるようにすることができるかどうか疑問に思っています..そして、それを閉じて、それは裏返されるので、私は再びレコードを見ることができます..

私はすべてのデモでjquery uiページを少し見ましたが、実際には何も見つかりませんでした...

どんな助けや指針も素晴らしいでしょう..あなたが何か似たような病気を知っていたとしても、喜んでそれを調べてください...

助けてくれてありがとう

4

3 に答える 3

1

分かりました、簡単な例をお見せしましょう。それはむしろ非常に簡単です

<table>
    <tr class="recordrow" id="row-1"> <!-- row-X will be the unique way to identify the row -->
       <td>...</td> <!-- The record field -->
       <td>...</td>
       ....
    </tr>
</table>

<!-- Now we create the details Div, but as reference to the `row-X` -->
<div class="details" id="details-1">
   ... More details of the records
</div>

次に、次のような単純なjQueryスニペットで作業が完了します。

$(".recordrow").click(function() {
    var divid = "details-" + $(this).attr('id').split("-")[1]; //Create the id of the div
    $("#"+divid).show().animate({ "left": '200px'}); //Bring the div from right to left with 200px padding from the screen
});

デモ

于 2012-08-31T02:06:50.903 に答える
1

わかりましたので、ここに私のフィドルがあります

HTML (標準コンテナなど)

<div id="container">
    <div id="buttons-container"></div>
    <div id="record">
        <div id="record-content"></div>            
        <a href="#" id="bt-close" onclick="closeRecord(); return false;">Close</a></div>
</div>

CSS

a.bt-record {
    display:block;
    width:100px;
    height:100px;
    background:#999999;
    color:#000;
    line-height:100px;
    text-align:center;
    float:left;
    margin:0 10px 10px 0;
    text-decoration:none;
}

a { color:#fff; }

#container {
    width:100%;
    height:100%;
    overflow:hidden;
    position:relative;
}

#record {
    position:absolute;
    right:-240px;
    top:100px;
    width:200px;
    height:200px;
    background:#000;
    padding:20px;
    color:#fff;
    z-index:1;
}

Javascript

//your data in a array of objects (could be something else)
var data = {
    1 : {name:'Record 1', text:'This is the text 1', options:'Anything 1'},
    2 : {name:'Record 2', text:'This is the text 2', options:'Anything 2'},
    3 : {name:'Record 3', text:'This is the text 3', options:'Anything 3'},
    4 : {name:'Record 4', text:'This is the text 4', options:'Anything 4'},
    5 : {name:'Record 5', text:'This is the text 5', options:'Anything 5'},
    6 : {name:'Record 6', text:'This is the text 6', options:'Anything 6'},
    7 : {name:'Record 7', text:'This is the text 7', options:'Anything 7'},
    8 : {name:'Record 8', text:'This is the text 8', options:'Anything 8'},
    9 : {name:'Record 9', text:'This is the text 9', options:'Anything 9'}
};

$(document).ready(function() {
    populateEntries();        
});

//dynamically populate the entries
function populateEntries() {
    for (entry in data){
console.log(entry);       
        $('#buttons-container').append('<a class="bt-record" href="#" onclick="showRecord(' + entry + '); return false;">' + data[entry].name + '</a>');
    }
}

//show the record
function showRecord(id) {
    //create the html
    var html = '';
    html += '<p>Name : ' + data[id].name + '</p>';
    html += '<p>Text : ' + data[id].text + '</p>';
    html += '<p>Name : ' + data[id].options + '</p>';
    $('#record-content').html(html);
    $('#record').animate({right:0}, 500);
}

function closeRecord() {
    $('#record').animate({right:-240}, 500);
}

この例では、レコードを動的に入力しますが、SEO に適した方法が必要な場合は、ページに直接 HTML を作成できます。ご不明な点がございましたら、お知らせください。

于 2012-08-31T02:10:09.007 に答える
0

次のように、個々の div ごとにクラスを追加します。

<div id="someid" class="clickable">
    your content here
    <div class="showonclick" style="visibility:hidden"> 
        The stuff to show on click here 
    </div>
</div>

<script type="text/javascript">
$(document).ready(function(){  
    $(".clickable").each(function() {
        var ref = this;
        $(ref).click(function() {
            $(ref + " .showonclick").fadeIn('slow');
        });
    });
});
</script>

基本的に、これは、ドキュメントの準備が整うとすぐに、指定されたクラスを持つ各 div にクリック ハンドラーを追加することです。

これがお役に立てば幸いです。

于 2012-08-31T01:53:42.317 に答える