Foros del Web » Programando para Internet » Jquery »

inconvenientes entre codigos jquery

Estas en el tema de inconvenientes entre codigos jquery en el foro de Jquery en Foros del Web. hola amigos estoy utilizando jquery para un menu y para un formulario pero funciona uno por separdo pero los dos al mismo tiempo no funcionan ...
  #1 (permalink)  
Antiguo 18/05/2012, 21:13
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
inconvenientes entre codigos jquery

hola amigos estoy utilizando jquery para un menu y para un formulario pero funciona uno por separdo pero los dos al mismo tiempo no funcionan

http://www.dynamicdrive.com/dynamici...smoothmenu.htm
http://www.webappers.com/2009/11/20/...m-with-jquery/


como hago para que los dos codigo no tengan conflictos

gracias
  #2 (permalink)  
Antiguo 18/05/2012, 21:21
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: inconvenientes entre codigos jquery

el codigo del menu

es este

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.  
  3. ddsmoothmenu.init({
  4.     mainmenuid: "smoothmenu1", //menu DIV id
  5.     orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
  6.     classname: 'ddsmoothmenu', //class added to menu's outer DIV
  7.     //customtheme: ["#1c5a80", "#18374a"],
  8.     contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
  9. })
  10.  
  11. ddsmoothmenu.init({
  12.     mainmenuid: "smoothmenu2", //Menu DIV id
  13.     orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
  14.     classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
  15.     //customtheme: ["#804000", "#482400"],
  16.     contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
  17. })
  18.  
  19. </script>


Código Javascript:
Ver original
  1. var ddsmoothmenu={
  2.  
  3. //Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):
  4. arrowimages: {down:['downarrowclass', 'down.gif', 23], right:['rightarrowclass', 'right.gif']},
  5. transition: {overtime:300, outtime:300}, //duration of slide in/ out animation, in milliseconds
  6. shadow: {enable:true, offsetx:5, offsety:5}, //enable shadow?
  7. showhidedelay: {showdelay: 100, hidedelay: 200}, //set delay in milliseconds before sub menus appear and disappear, respectively
  8.  
  9. ///////Stop configuring beyond here///////////////////////////
  10.  
  11. detectwebkit: navigator.userAgent.toLowerCase().indexOf("applewebkit")!=-1, //detect WebKit browsers (Safari, Chrome etc)
  12. detectie6: document.all && !window.XMLHttpRequest,
  13. css3support: window.msPerformance || (!document.all && document.querySelector), //detect browsers that support CSS3 box shadows (ie9+ or FF3.5+, Safari3+, Chrome etc)
  14.  
  15. getajaxmenu:function($, setting){ //function to fetch external page containing the panel DIVs
  16.     var $menucontainer=$('#'+setting.contentsource[0]) //reference empty div on page that will hold menu
  17.     $menucontainer.html("Loading Menu...")
  18.     $.ajax({
  19.         url: setting.contentsource[1], //path to external menu file
  20.         async: true,
  21.         error:function(ajaxrequest){
  22.             $menucontainer.html('Error fetching content. Server Response: '+ajaxrequest.responseText)
  23.         },
  24.         success:function(content){
  25.             $menucontainer.html(content)
  26.             ddsmoothmenu.buildmenu($, setting)
  27.         }
  28.     })
  29. },
  30.  
  31.  
  32. buildmenu:function($, setting){
  33.     var smoothmenu=ddsmoothmenu
  34.     var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
  35.     $mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"
  36.     var $headers=$mainmenu.find("ul").parent()
  37.     $headers.hover(
  38.         function(e){
  39.             $(this).children('a:eq(0)').addClass('selected')
  40.         },
  41.         function(e){
  42.             $(this).children('a:eq(0)').removeClass('selected')
  43.         }
  44.     )
  45.     $headers.each(function(i){ //loop through each LI header
  46.         var $curobj=$(this).css({zIndex: 100-i}) //reference current LI header
  47.         var $subul=$(this).find('ul:eq(0)').css({display:'block'})
  48.         $subul.data('timers', {})
  49.         this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
  50.         this.istopheader=$curobj.parents("ul").length==1? true : false //is top level header?
  51.         $subul.css({top:this.istopheader && setting.orientation!='v'? this._dimensions.h+"px" : 0})
  52.         $curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images
  53.             '<img src="'+ (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])
  54.             +'" class="' + (this.istopheader && setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])
  55.             + '" style="border:0;" />'
  56.         )
  57.         if (smoothmenu.shadow.enable && !smoothmenu.css3support){ //if shadows enabled and browser doesn't support CSS3 box shadows
  58.             this._shadowoffset={x:(this.istopheader?$subul.offset().left+smoothmenu.shadow.offsetx : this._dimensions.w), y:(this.istopheader? $subul.offset().top+smoothmenu.shadow.offsety : $curobj.position().top)} //store this shadow's offsets
  59.             if (this.istopheader)
  60.                 $parentshadow=$(document.body)
  61.             else{
  62.                 var $parentLi=$curobj.parents("li:eq(0)")
  63.                 $parentshadow=$parentLi.get(0).$shadow
  64.             }
  65.             this.$shadow=$('<div class="ddshadow'+(this.istopheader? ' toplevelshadow' : '')+'"></div>').prependTo($parentshadow).css({left:this._shadowoffset.x+'px', top:this._shadowoffset.y+'px'})  //insert shadow DIV and set it to parent node for the next shadow div
  66.         }
  67.         $curobj.hover(
  68.             function(e){
  69.                 var $targetul=$subul //reference UL to reveal
  70.                 var header=$curobj.get(0) //reference header LI as DOM object
  71.                 clearTimeout($targetul.data('timers').hidetimer)
  72.                 $targetul.data('timers').showtimer=setTimeout(function(){
  73.                     header._offsets={left:$curobj.offset().left, top:$curobj.offset().top}
  74.                     var menuleft=header.istopheader && setting.orientation!='v'? 0 : header._dimensions.w
  75.                     menuleft=(header._offsets.left+menuleft+header._dimensions.subulw>$(window).width())? (header.istopheader && setting.orientation!='v'? -header._dimensions.subulw+header._dimensions.w : -header._dimensions.w) : menuleft //calculate this sub menu's offsets from its parent
  76.                     if ($targetul.queue().length<=1){ //if 1 or less queued animations
  77.                         $targetul.css({left:menuleft+"px", width:header._dimensions.subulw+'px'}).animate({height:'show',opacity:'show'}, ddsmoothmenu.transition.overtime)
  78.                         if (smoothmenu.shadow.enable && !smoothmenu.css3support){
  79.                             var shadowleft=header.istopheader? $targetul.offset().left+ddsmoothmenu.shadow.offsetx : menuleft
  80.                             var shadowtop=header.istopheader?$targetul.offset().top+smoothmenu.shadow.offsety : header._shadowoffset.y
  81.                             if (!header.istopheader && ddsmoothmenu.detectwebkit){ //in WebKit browsers, restore shadow's opacity to full
  82.                                 header.$shadow.css({opacity:1})
  83.                             }
  84.                             header.$shadow.css({overflow:'', width:header._dimensions.subulw+'px', left:shadowleft+'px', top:shadowtop+'px'}).animate({height:header._dimensions.subulh+'px'}, ddsmoothmenu.transition.overtime)
  85.                         }
  86.                     }
  87.                 }, ddsmoothmenu.showhidedelay.showdelay)
  88.             },
  89.             function(e){
  90.                 var $targetul=$subul
  91.                 var header=$curobj.get(0)
  92.                 clearTimeout($targetul.data('timers').showtimer)
  93.                 $targetul.data('timers').hidetimer=setTimeout(function(){
  94.                     $targetul.animate({height:'hide', opacity:'hide'}, ddsmoothmenu.transition.outtime)
  95.                     if (smoothmenu.shadow.enable && !smoothmenu.css3support){
  96.                         if (ddsmoothmenu.detectwebkit){ //in WebKit browsers, set first child shadow's opacity to 0, as "overflow:hidden" doesn't work in them
  97.                             header.$shadow.children('div:eq(0)').css({opacity:0})
  98.                         }
  99.                         header.$shadow.css({overflow:'hidden'}).animate({height:0}, ddsmoothmenu.transition.outtime)
  100.                     }
  101.                 }, ddsmoothmenu.showhidedelay.hidedelay)
  102.             }
  103.         ) //end hover
  104.     }) //end $headers.each()
  105.     if (smoothmenu.shadow.enable && smoothmenu.css3support){ //if shadows enabled and browser supports CSS3 shadows
  106.         var $toplevelul=$('#'+setting.mainmenuid+' ul li ul')
  107.         var css3shadow=parseInt(smoothmenu.shadow.offsetx)+"px "+parseInt(smoothmenu.shadow.offsety)+"px 5px #aaa" //construct CSS3 box-shadow value
  108.         var shadowprop=["boxShadow", "MozBoxShadow", "WebkitBoxShadow", "MsBoxShadow"] //possible vendor specific CSS3 shadow properties
  109.         for (var i=0; i<shadowprop.length; i++){
  110.             $toplevelul.css(shadowprop[i], css3shadow)
  111.         }
  112.     }
  113.     $mainmenu.find("ul").css({display:'none', visibility:'visible'})
  114. },
  115.  
  116. init:function(setting){
  117.     if (typeof setting.customtheme=="object" && setting.customtheme.length==2){ //override default menu colors (default/hover) with custom set?
  118.         var mainmenuid='#'+setting.mainmenuid
  119.         var mainselector=(setting.orientation=="v")? mainmenuid : mainmenuid+', '+mainmenuid
  120.         document.write('<style type="text/css">\n'
  121.             +mainselector+' ul li a {background:'+setting.customtheme[0]+';}\n'
  122.             +mainmenuid+' ul li a:hover {background:'+setting.customtheme[1]+';}\n'
  123.         +'</style>')
  124.     }
  125.     this.shadow.enable=(document.all && !window.XMLHttpRequest)? false : this.shadow.enable //in IE6, always disable shadow
  126.     jQuery(document).ready(function($){ //ajax menu?
  127.         if (typeof setting.contentsource=="object"){ //if external ajax menu
  128.             ddsmoothmenu.getajaxmenu($, setting)
  129.         }
  130.         else{ //else if markup menu
  131.             ddsmoothmenu.buildmenu($, setting)
  132.         }
  133.     })
  134. }
  135.  
  136. }

y el del formulario

<script type="text/javascript">
$(document).ready(function() {

$(".signin").click(function(e) {
e.preventDefault();
$("fieldset#signin_menu").toggle();
$(".signin").toggleClass("menu-open");
});

$("fieldset#signin_menu").mouseup(function() {
return false
});
$(document).mouseup(function(e) {
if($(e.target).parent("a.signin").length==0) {
$(".signin").removeClass("menu-open");
$("fieldset#signin_menu").hide();
}
});

});
</script>
<script type='text/javascript'>
$(function() {
$('#forgot_username_link').tipsy({gravity: 'w'});
});
</script>

que puedo hacer para que no hay conflicto ?
  #3 (permalink)  
Antiguo 18/05/2012, 21:34
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: inconvenientes entre codigos jquery

hola amigos el error ya lo encontre

este fragmento de codigo lo copie 2 veces

Código Javascript:
Ver original
  1. ddsmoothmenu.init({
  2.     mainmenuid: "smoothmenu2", //Menu DIV id
  3.     orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
  4.     classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
  5.     //customtheme: ["#804000", "#482400"],
  6.     contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
  7. })

Etiquetas: codigos, formulario, funcion, inconvenientes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:44.