0
When I mark in html it works normally, when I write in my jQuery sheet using the api (). html doesn’t work, I’m guessing it’s because of the date-written in the div, how I could make it work?
$(function(){
$('.bl6-conteudo').html([
'<div class="cycle-slideshow"',
'data-cycle-fx="fade"',
'data-cycle-timeout="240000"',
'data-cycle-slides="> .dicas"',
'data-cycle-caption-plugin="caption2"',
'data-cycle-pager-template="">',
'<div class="cycle-prev"></div>',
'<div class="cycle-next"></div>',
'<div class="cycle-caption"></div>',
'<div class="bl6-d1 dicas"></div>',
'<div class="bl6-d2 dicas"></div>',
'<div class="bl6-d3 dicas"></div>',
'<div class="bl6-d4 dicas"></div>',
'<div class="bl6-d5 dicas"></div>',
'<div class="bl6-d6 dicas"></div>',
'</div>'
].join(''));
})
I was able to solve this problem by making the call, on the sheet of my scripts, as @Luiztanure said and restarted @Fabriciomatte.
$( '.cycle-slideshow' ).cycle();
And in the HTML sheet I set the scripts this way:
<!-- jquery -->
// jquery library
<!-- Cycle2 -->
<script src="js/jquery.cycle2.js"></script> // tem de ficar logo acima da chamada dependende
<!-- Minha folha de scripts-->
<script type="text/javascript" src="js/jquery.meu.js"></script> // cycle2 depende dessa folha , pois tem partes do arquivo carregando nessa folha
Only then was it possible to make the plug work right , when inserted via . html() straight into my script sheet (my.js).
It is necessary to be careful with the order of the calls.
@Pauloroberto There is really no problem any content insertion via Jquery/javascript, I only see advantages, even as a string, in fact besides being easier not found relevant contraindications. See when inspecting element that appears as if it were inserted directly into html, besides being easy to edit, and loading the page is fast too.
vlw ;)
I believe it’s because Cycle checks the existence of
.cycle-slideshow
and initializes them before of your code that creates it. In this case you can call the$( '.cycle-slideshow' ).cycle();
manually as Luiz did in the fiddle of his answer.=]
– Fabrício Matté
Can you add more code? Where to initialize
cicle()
?– Sergio
I’m trying to call but it’s not working, I’ll keep trying. Sergio cicle() initializes in the sheet I downloaded already ready that integrates the plugin, the rest is basically data- inside the div.
– Thiago Jem