Autor | Zpráva | ||
---|---|---|---|
T-fon Profil |
Ahoj, toto je část kódu z wysiwygu, kde se přidávají videa:
this.createVideoNode = function (url) { //... var $video; if (ytMatch && ytMatch[1].length === 11) { var youtubeId = ytMatch[1]; $video = $('<iframe allowfullscreen>') .attr('src', 'https://www.youtube.com/embed/' + youtubeId); } else if //... $video.addClass('embed-responsive-item'); return $video[0]; }; A já si tam přidal wrap, aby bylo responzivní: $video = $('<iframe allowfullscreen>') .attr('src', 'https://www.youtube.com/embed/' + youtubeId) .wrap('<div class="embed-responsive embed-responsive-16by9"></div>'); Iframe se ale divem neobalí. Prosím o pomoc se správným postupem. Edit: zkusil jsem wrap přidat až na konec (za addClass), ale taky bez úspěchu ( $video.wrap('<div class="embed-responsive embed-responsive-16by9"></div>'); )
|
||
Kajman Profil |
V DOM v paměti se tam ten div kolem dá, ale funkce stále vrací odkaz na element iframe. A následný kód, který element vrácený funkcí dá někam do DOM stránky, tedy ten div nepoužije.
Pokud se třída embed-responsive-item má nastavit tomu divu, tak do $video můžete uložit ten div díky $video=...wrap(...).parent() a pak se při větvi yt vrátí div obsahující iframe.
Pokud třída embed-responsive-item patří iframe, tak třeba až před return můžete dát $video=$('<div class="embed-responsive embed-responsive-16by9"></div>').prepend($video); |
||
T-fon Profil |
#3 · Zasláno: 14. 3. 2018, 12:13:55
Je to Bootstrap 4, třída item patří iframu. Funguje to perfektně takhle s prepend. Díky moc.
|
||
Časová prodleva: 5 let
|
0