2012-02-11 28 views
1

onLayout同位体で関数を呼び出すと、それはこのことを言う/定義:私は<a href="http://isotope.metafizzy.co/docs/options.html#onlayout" rel="nofollow">http://isotope.metafizzy.co/docs/options.html#onlayout</a>を使用してい

「似コールバックに、onLayoutは、同位体のインスタンスがレイアウトロジックを通るたびに、後にトリガーされる関数であります" 「レイアウト」は終了したときに、私はこの実行できることを意味し

$('#container').isotope({ 
    onLayout: function($elems) { 
    // `this` refers to jQuery object of the container element 
    console.log(this.height()); 
    // callback provides jQuery object of laid-out item elements 
    $elems.css({ background: 'blue' }); 
    } 
}); 

$elems.css({ background: 'blue' }); 

私はしかし、私はそれを理解することができるものから、「$ elems」を持っていませんが、その時に「on​​Layout」を意味します終了している私が欲しいものを実行することができますし、私はこれを実行したいと思います:

$("#container").width(); 
$("#head").animate({ width: newWidth}, "fast"); 

をしかし、「()」内「$ elems」何としていますか?

おかげ

+1

私はあなたが何をしたいのか理解していませんよ。別の時間に呼び出すことができる 'onLayout'関数を定義しようとしていますか?もしそうなら、あなたはそれを呼びたいと思っていますか?そうでない場合、あなたがしたいことをより詳細に記述してください。 – jfriend00

+0

私の質問を更新 –

答えて

1

あなたはそうのような要素へのカスタムイベントバインドすることができます。

$('#container').bind('my_event', function() 
{ 
    alert('my_event has just fired!'); 
}); 

をそして.trigger()でそれを呼び出す:

$('#container').trigger('my_event'); 

これを使用して、設定することができるはずですあなたが非常に簡単にしたいことをアップ、私は思う。


更新:

代わりにこのコードを呼び出す:

$('#container').isotope({ 
    onLayout: function($elems) { 
    // `this` refers to jQuery object of the container element 
    console.log(this.height()); 
    // callback provides jQuery object of laid-out item elements 
    $elems.css({ background: 'blue' }); 
    } 
}); 

コールこの:

$('#container').isotope({ 
    onLayout: function($elems) { 
     // `this` refers to jQuery object of the container element 
     console.log(this.height()); 
     // callback provides jQuery object of laid-out item elements 
     $elems.css({ background: 'blue' }); 
     $("#container").width(); 
     $("#head").animate({ width: newWidth}, "fast"); 
    } 
}); 
+0

私はこのonLayoutの後にちょうど私のビットを実行する必要があります:function($ elems){例としては –

+1

と言います。 Sec :) – Joe

+0

ありがとう、ありがとう:) –

関連する問題