- Screen name: alexmcauley
alexmcauley's Profile
8 Posts
20 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- Good afternoon people.
I have a slight issue with namespacing click events.
Currently I have a function that is in use on every page of a site I have been working on that uses live() to bind click hanlders to some <a> tags (which works perfectly).
I now have one page that needs to add some extra functionality to those <a> tags on this page -only-, so I decided to namespace the click. Namespacing it works fine with one caveat - it executes the namespaced handler before the original handler which creates havok with the original function. The havok is created because the namespaced handler removes an element that the original live() handler relies on for certain things.
What I wondered is if anyone knows a way to have the original hanlder executed first before the namespaced one and my problem will go away.
If this is not possible perhaps someone knows a way I can extend the original live() handler (on this one page only) to do some extra stuff after it's normal funcitonality.
Thanks in advance
Alex
[edit]
From the jquery docs..
When an event reaches an element, all handlers bound to that event type for the element are fired. If there are multiple handlers registered, they will always execute in the order in which they were bound. After all handlers have executed, the event continues along the normal event propagation path.
Does this mean they go from last to first or first to last?- Hi I seem to have this error when using the datepicker.
I am using a custom build from the UI website which does have the zIndex() function included in it and i just cant work out what is going wrong... Can someone please help !!- Hi guys
I am writing a plugin to wrap some suggestive searching into an application.
I needed many suggestive's on one page so i decided to write a plugin to do it..
The plugin is going okay except I am a bit stuck with 1 line of the javascript.
This might be a bit off topic but i thought i would ask.
In short my suggestive uses timeouts to send the values to the server to get some text back... It basically sets a timeout on a keyup and cancels / resets on the next press... for example if you type a letter then another one within 600ms the first request is canceled and the second one starts the timeout loop again and so on (saves on mass server load).. I have this working properly except the timeouts is a global variable which i need to change into the scope of the plugin...
For example in the global sense the following code works fine.- var timeouts;
- if(timeouts) { clearTimeout(timeouts); }
- //... my code to create the container etc etc (boring and not needed for this example)
- timeouts=window.setTimeout(function() {
$.post("/suggestive-search",{ query: string},
function(data){
$("#qs-results").html(data);
$("#qs-results").fadeIn(400);
});
},600); // end window settimeouts
- var rand=new Date().getTime();
var timeouts+'-'+rand;
if(timeouts+''+rand) { clearTimeout(timeouts+''+rand); } - // boring code all working
timeouts+''+rand=window.setTimeout(function() {
$.post("/suggestive-search",{ query: text},
function(data){
$("#"+settings.ResultsId+"").html(data);
$("#"+settings.ResultsId+"").fadeIn(400);
});
},600); // end window settimeouts
Kind regarsds- Good morning
I have a slight problem in FF3.5 that unbind('keydown'); is not working properly..
$("#q").unbind('keydown');
$("#q").keydown(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
if(code==40 || code==38) {
var totalResults=$("#quick-search-results li");
var selectedResults=$("#quick-search-results li.qs-selected");
if(code==40) {
var nodeIndex=($("#quick-search-results li.qs-selected").length<=0) ? 0 : $("#quick-search-results").index('li.qs-selected');
alert(nodeIndex);
}
}
}); // end keydown
The above code alerts once on first keydown (with the down arrow key [code==40]), twice on the second, three times on the third and so on.. it worked fine in FF3 but a recent upgrade to FF3.5 seems to have broken the functionality..
Has anyone else had this problem ?
Thanks in advance.
AlexMorning peoples.
I keep getting the following error when i am working with some positioning in jquery
Permission denied to access property 'nodeType' from a non-chrome context
The code is below that triggers the error...
- $(document).ready(function(){
- $(".stacked-window").live("mouseenter", function(e){
var element=$(this);
var rand=$(this).find('.rand').val();
var text=$("#stacked-tooltip-"+rand+"").html();
var height=element.outerHeight();
var left=Math.round(element.offset().left);
var top=Math.round((element.offset().top - ( height / 2 ) ));
$("<div/>",{
id: 'tooltip-'+rand,
'class': 'dock-tooltip',
css :
{
'position': 'absolute',
'z-index': 999,
'left': left+'px',
'top': top+'px',
'display': 'none'
},
html : text
}).appendTo("#container").show("fast");
});
$(".stacked-window").live("mouseleave", function(){
var element=$(this);
var rand=$(this).find('.rand').val();
$("#tooltip-"+rand+"").remove();
}); - $("#dock-hover").mouseenter(function(){
$("#dock").fadeIn("fast");
});
$("#dock-hover").mouseleave(function(){
$("#dock").fadeOut(400);
});- }); // end document ready
The error does not happen all the time - only when i seem to mouseleave the tooltip element quickly and the hover element...
Has anyone every encountered a problem like this or is it a known bug ?
Thanks in advance
/Alex
- 21-Jan-2010 11:04 AM
- Forum: Using jQuery Plugins
Didnt really know where to post this and here seemed more approriate than anywhere else..
For a couple of years i have been developing a web type desktop using prototypejs/scripty/jquery..
WIth the release of jQuery 1.4 i completley ported it over to use only jquery (which gave a few performance improvements)...I am quite new to writing jQuery for apps (on its own) so it's a good learning curve for me.
The system itself relies on jquery 1.4, ui core, resizable, draggable and nothing else (though you can plugin whatever you like)..
The system is themeable (though i am not that graphical so i hacked together a theme this morning to showcase it.
I decided to not support IE6 because lets be honest its a pita !
It is cross browser (though a couple of IE7 quirks to iron out and untested on webkit but i'm sure it will be fine)
I am looking for anyone who would like to get involved in the project and help develop it - my current prototype based system is used daily in a number of businesses as a CRM / CMS and controls everything from invoicing to managing holidays for employees and everything in between. The business applications are obvious but i am sure it can be ported and mashed up nicely in a social sense.
The code and API is very simple and weighs in about 10k unpacked/non minimised and with alot that could be cleaned up so it can probably drop to around 3k.
the demo is at http://desktop.bazookawally.co.uk/ to open a window double click the "Spawn Window" element on the desktop (which is draggable) - then you can play with the spawned window (resize, drag, change tooltips and titles for the window etc etc). The code is like 0.1 release and POC really (though i know it is robust enough to be used in a live environment).
Forgot to add: (edit) .. each page is loaded via ajax so the internal page itself can be anythign you like - i simply load a php page inside it (no iframe)
If anyone would like to get involved just send me an email alex@bazookawally.co.uk. I would like to get the project on github as i think it has real potential and is very flexible indeed.
/Alex
- 20-Jan-2010 05:33 AM
- Forum: Using jQuery
Morning peoples.
I think i have found a possible bug in 1.4 but it's only in Internet Explorer 7 & 8.
The following code does not work and completely ruins every peice of jquery on the page (that means everything inside $(document).ready and anyting else...
$("<div/>",{
id: 'tooltip-'+rand,
class: 'dock-tooltip',
css :
{
'position': 'absolute',
'z-index': '999',
'left': left+'px',
'bottom': '32px',
'display': 'none'
},
html : text
}).appendTo("#container").show("fast");Yet this code works fine.
$('<div id="tooltip-'+rand+'" class="dock-tooltip"><div class="tooltip-top">'+text+'</div></div>').css({'position':'absolute','z-index':'999','left':left+'px', 'display':'none'}).appendTo("#container").show("fast");
I cant see any syntax errors - i pulled the example from the 1.4 site. There is no trailing commas in the object notation and i really cant see any reason it would work in firefox and not IEx and more to the point not only not work in IEx but break any other jquery in the entire page....
Not really sure where to post the possible bug to either !
Anyone have any suggestions ?
Thanks in advance
Alex
Morning peoples.
I am in the process of porting an application i have been building for a couple of years to jQuery from jquery/prototypejs&scriptaculous.
Reading the new documentation i see that bind can take multiple observers (for example)
$("div.test").bind({
click: function(){
$(this).addClass("active");
},
mouseenter: function(){
$(this).addClass("inside");
},
mouseleave: function(){
$(this).removeClass("inside");
}
});Is this also true with "live" ( i am adding alot of dynamic elements to a page that have tooltips attached to them and have written a simple tooltip plugin that uses live to stop me constantly needing to call the plugin everytime somehting on the page changes to do with the tooltip..
Thanks in advance.
PS. adding this question was really slow and resource hungry it rocketd my CPU to 100% (is anyone aware of this)!
- «Prev
- Next »
- $(document).ready(function(){
Moderate user : alexmcauley
© 2013 jQuery Foundation
Sponsored by and others.

