Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

fmaciel3

[Resolvido] 2 ou mais JQuery na mesma página dá problema.

Recommended Posts

importe o jQuery uma única vez!!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Primms - Construtora e Incorporadora | Gravataí/RS</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css" />
<link href="css/menu.css" rel="stylesheet" type="text/css" media="screen"/>

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript">
 //Associo o jQuery a uma variavél qualquer
var xyz = jQuery.noConflict();
</script>


<link href="css/slideshow.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/responsiveslides.min.js"></script>
<script type="text/javascript">
  $(function() {
    $(".rslides").responsiveSlides();
  });
</script>


</head>


<body>

Compartilhar este post


Link para o post
Compartilhar em outros sites

aperte Ctrl + Shift + J no Firefox e veja oq aparece no console de erros.

 

mantenha o código q sugeri.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Deixe o código assim agora:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Primms - Construtora e Incorporadora | Gravataí/RS</title>

<link href="css/estilos.css" rel="stylesheet" type="text/css" />

<link href="css/menu.css" rel="stylesheet" type="text/css" media="screen"/>

 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

<script type="text/javascript" src="js/menu.js"></script>

 

 

 

<link href="css/slideshow.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/responsiveslides.min.js"></script>

 

 

</head>

Removi aquela parte do noConflict, pq vc não precisa dela.

Compartilhar este post


Link para o post
Compartilhar em outros sites

aqui funcionou tudo. Qual a sua dúvida ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

o problema agora é o seu script. O conflito já resolvemos.

 

no arquivo menu.js

troque:

	initwidth = $("li").width();
	$("li").hover( function(){
por:
	initwidth = $("#menu li").width();
	$("#menu li").hover( function(){

Compartilhar este post


Link para o post
Compartilhar em outros sites

William Bruno

 

Socorro, precise incluir mais uma biblioteca o lightbox

 

e pra variar deu pau.

 

http://www.construtoraprimms.com.br/index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Primms - Construtora e Incorporadora | Gravataí/RS</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css" />
<link href="css/menu.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="css/slideshow.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/menu.js"></script>
<script type="text/javascript" src="js/responsiveslides.min.js"></script>
<script type="text/javascript" src="js/banner.js"></script>


<!-- O resto pra cima esta funfando aki que não abre o efeito ao clicar na imagem-->
<script type="text/javascript" src="js/lightbox.js"></script>


</head>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

use outra lib de lightbox, essa ai é problemática.

Compartilhar este post


Link para o post
Compartilhar em outros sites

William Bruno beleza?

 

To com o mesmo problema da galera, tenho dois códigos de jquery na minha página e eles entram em conflito.

 

No caso esses códigos ficam no head:

 

<link rel="stylesheet" href="index_files/vlb_files1/vlightbox1.css" type="text/css" />
<link rel="stylesheet" href="index_files/vlb_files1/visuallightbox.css" type="text/css" media="screen" />
<script src="index_files/vlb_engine/jquery.min.js" type="text/javascript"></script>
<script src="index_files/vlb_engine/visuallightbox.js" type="text/javascript"></script>
E esse no fim antes de fechar a body: (animação da âncora)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript">
$(function() {
$('ul li a').bind('click',function(event){
var $anchor = $(this);
/*
if you want to use one of the easing effects:
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1500,'easeInOutExpo');
*/
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1000);
event.preventDefault();
});
})
</script>

 

 

Obrigado!

Compartilhar este post


Link para o post
Compartilhar em outros sites

@William Bruno, estou tendo o mesmo problema dos outros citados acima, só que com uma particularidade.

Estou importando um jquery.min, mas ele está dando conflito com o jquery de uma biblioteca que eu não tenho acesso, ai fica minha duvida de como resolver o conflito..

Segue o código completo: 

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Cadastrar Usuário</title>
        <script type="text/javascript" src="jquery.min.js"></script>
        <link rel="stylesheet" href="mypattern.css"/>
    </h:head>
    <h:body style="background-color: #{config.BackgroudColor}">
        <h:form id="form" acceptcharset="ISO-8859-1">
            <ui:include src="/topo.xhtml"/>
            <p:panel header="Cadastro de usuário" toggleable="true" toggleTitle="Minimizar">
                <p:panelGrid columns="2">
                    <p:outputLabel value="Nome" for="nome"/>
                    <p:inputText id="nome" value="#{userController.usuarios.nome}" onkeypress="return checkValidChar(this,'0123456789abcdefghijlmnopqrstuvxzwykABCDEFGHIJLMNOPQRSTUVXZWYK-_ ','Não é possível inserir caracteres especiais. !@#ç$%',event);" required="true" requiredMessage="O campo nome é obrigatório."/>
                    <p:outputLabel value="Matrícula" for="matricula"/>
                    <p:inputText id="matricula" value="#{userController.usuarios.matricula}" onkeypress="return checkValidChar(this,'0123456789abcdefghijlmnopqrstuvxzwykABCDEFGHIJLMNOPQRSTUVXZWYK-_ ','Não é possível inserir caracteres especiais. !@#ç$%',event);" required="true" requiredMessage="O campo matrícula é obrigatório."/>
                    <p:outputLabel value="Senha" for="new_senha"/>
                    <p:password feedback="true" goodLabel="Média" weakLabel="Fraca" strongLabel="Segura" promptLabel="Por favor, digite a senha" id="new_senha" value="#{userController.usuarios.senha}" required="true" requiredMessage="O campo senha é obrigatório."/>

                    <p:outputLabel value="Regional" for="regional"/>
                    <p:autoComplete id="regional" value="#{userController.cidade}"
                                    completeMethod="#{userController.completeCidades}"
                                    var="cidade"
                                    itemLabel="#{cidade.cidade}"
                                    itemValue="#{cidade}"
                                    maxResults="8"
                                    forceSelection="true"
                                    tabindex="1">
                        <p:ajax event="itemSelect"/>
                    </p:autoComplete>
                </p:panelGrid>

                <p:dataTable id="table_cidades" style="width: 70%" var="cid" value="#{userController.dataModel}"
                             selection="#{userController.hasUsuarios}" rowKey="#{cid.regionaisHasUsuariosPK.id}" selectionMode="single">
                    <f:facet name="header">
                        Lista de Cidades
                    </f:facet>

                    <p:ajax event="rowSelect"/>

                    <p:column headerText="ID">
                        #{cid.cidades.id}
                    </p:column>

                    <p:column headerText="Cidade">
                        #{cid.cidades.cidade}
                    </p:column>

                </p:dataTable>
                <p:commandButton value="Adicionar" actionListener="#{userController.addCidadeInList}" update="table_cidades, msg, regional" immediate="true"/>
                <p:commandButton value="Remover" actionListener="#{userController.removeCidadeFromList}" update="table_cidades, msg, regional" immediate="true"/>

                <p:selectManyCheckbox layout="pageDirection" value="#{userController.permissoes}">
                    <f:selectItem itemLabel="Solicitação" itemValue="1" />
                    <f:selectItem itemLabel="Triagem" itemValue="2" />
                    <f:selectItem itemLabel="Expedição" itemValue="3" />
                    <f:selectItem itemLabel="Estoque" itemValue="4" />
                    <f:selectItem itemLabel="Administração" itemValue="5" />
                </p:selectManyCheckbox>
            </p:panel>
            <p:commandButton value="Salvar" action="#{userController.salvarForm()}" ajax="false"/>
            <p:commandButton value="Voltar" action="#{userController.voltar}" ajax="false" immediate="true"/>
        </h:form>
        <script type="text/javascript" src="mypattern.js"></script>
    </h:body>
</html>

Ai essa jquery: 

        <script type="text/javascript" src="jquery.min.js"></script>

Está dando conflito com a usada na biblioteca primefaces quando utilizo a funçao autocomplete que é originada dela:

		<p:autoComplete id="regional" value="#{userController.cidade}"
                                    completeMethod="#{userController.completeCidades}"
                                    var="cidade"
                                    itemLabel="#{cidade.cidade}"
                                    itemValue="#{cidade}"
                                    maxResults="8"
                                    forceSelection="true"
                                    tabindex="1">
                        <p:ajax event="itemSelect"/>
                    </p:autoComplete>

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.