Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!

Dromio posted:

I'm trying to integrate my jQuery-heavy page into a site that was already using scriptaculous/prototype. I've put "jQuery.noConflict();" so it runs immediately and I've replaced all instances of "$" with "jQuery" in my code.

But I'm still getting an error in jquery.js claiming "this.cloneNode is not a function". It's coming from somewhere inside one of one of my jquery plugins.

Any suggestions on how to hunt it down?

Are you sure jQuery is loaded at the time that function is called? Wrapped everything in a jQuery(function(){})?

Adbot
ADBOT LOVES YOU

Dromio
Oct 16, 2002
Sleeper

LOLLERZ posted:

Are you sure jQuery is loaded at the time that function is called? Wrapped everything in a jQuery(function(){})?
Yes, it's coming from (deep) inside a jQuery(document).ready(function(){ call.

epswing
Nov 4, 2003

Soiled Meat
I'll just jump right in.

I have a bunch of these...
code:
<input id="id1" value="hi" />
<input id="id2" value="there" />
...and one of these...
code:
var data = { a: "#id1", b: "#id2" };
...and I want that to become...
code:
{ a: "hi", b: "there" }
Apparently this is a harder problem than it looks. I've tried a variety of things with .map and .each, but nothing so far will allow me to produce an object, with associations intact, containing the val()s of the strings of the values of the original object.

:(

Suggestions?

Edit: Nothing with .map will work, because .map only operates on arrays, not objects.

This alerts exactly what I want my resulting object to look like. I know exactly what I want to do, I just don't know how.
code:
$.each(data, function(key, val) { alert(key + ':' + $(val).val()); })

epswing fucked around with this message at 17:51 on Oct 31, 2008

sonic bed head
Dec 18, 2003

this is naturual, baby!

epswing posted:

I'll just jump right in.

I have a bunch of these...
code:
<input id="id1" value="hi" />
<input id="id2" value="there" />
...and one of these...
code:
var data = { a: "#id1", b: "#id2" };
...and I want that to become...
code:
{ a: "hi", b: "there" }
Apparently this is a harder problem than it looks. I've tried a variety of things with .map and .each, but nothing so far will allow me to produce an object, with associations intact, containing the val()s of the strings of the values of the original object.

:(

Suggestions?


Hopefully this puts you in the right direction.

code:
var data = { a: "#id1", b: "#id2" };

for(value in data){
var id = data[value];
var inputValue = $(id).value;
data[value]=inputValue;
}

epswing
Nov 4, 2003

Soiled Meat

sonic bed head posted:

Hopefully this puts you in the right direction.

Much thanks, this is what I'm using now:

code:
function mapvals(obj) {
    var out = {};
    for (key in obj) out[key] = $(obj[key]).val();
    return out;
}

sonic bed head
Dec 18, 2003

this is naturual, baby!

epswing posted:

Much thanks, this is what I'm using now:

code:
function mapvals(obj) {
    var out = {};
    for (key in obj) out[key] = $(obj[key]).val();
    return out;
}

Awesome

I have a question in general about jQuery, and this is coming as a prototype/scriptaculous man myself. Why would you need a .val() method for a dom element instead of just getting the field .value? Isn't there some overhead associated with calling a function instead of getting a property? Is there something I'm missing as to how that works? I can see the slight use of $F(id) for the value of an input box in prototype, because at least it's less typing but .val() and .value are the exact same amount of characters.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

sonic bed head posted:

Awesome

I have a question in general about jQuery, and this is coming as a prototype/scriptaculous man myself. Why would you need a .val() method for a dom element instead of just getting the field .value? Isn't there some overhead associated with calling a function instead of getting a property? Is there something I'm missing as to how that works? I can see the slight use of $F(id) for the value of an input box in prototype, because at least it's less typing but .val() and .value are the exact same amount of characters.

You don't really, but .val() is a setter and a getter, so it's "habit" to use that.

oryx
Nov 14, 2004




Fun Shoe

Dromio posted:

I'm trying to integrate my jQuery-heavy page into a site that was already using scriptaculous/prototype. I've put "jQuery.noConflict();" so it runs immediately and I've replaced all instances of "$" with "jQuery" in my code.

But I'm still getting an error in jquery.js claiming "this.cloneNode is not a function". It's coming from somewhere inside one of one of my jquery plugins.

Any suggestions on how to hunt it down?

I am assuming that you already went through the plugins to check to see if they had any instances of "$" in them, and also tried the extreme version of noConflict, noConflict(true).

That said, what version of jQuery are you using? In 1.2.6, cloneNode only comes into play in the clone function in jQuery, so you might want to start looking through the plugins for that kind of thing. It sounds like one of the plugins is using clone on an object that isn't a dom node, or is accidentally overwriting the cloneNode function. If you tell us the name of the plugins, I could help a bit more.

Dromio
Oct 16, 2002
Sleeper
oryx: Thanks, but I got it worked out. So many days ago I don't even remember how. Sorry I didn't post the resolution at the time, I usually try to do that.

MononcQc
May 29, 2007

Dromio posted:

oryx: Thanks, but I got it worked out. So many days ago I don't even remember how. Sorry I didn't post the resolution at the time, I usually try to do that.

I had a similar problem which was attributed to using an older version of scriptaculous. The explanation I heard was that it was prototyping the default javascript array, causing bugs in other stuff, but I'm not quite sure about that last part.

--

I'm wondering if there's a way to override some effects, or just stop them. What I'd like to do is basically having a div that will gradually fade out, unless the mouse enters it, where it'd gain 100% opacity back.

The problem is that even if I use $('#mydiv').hide(), or some flavour of $.fadeTo(), $.fadeIn() or $.fadeOut(), I can't seem to be able to stop the fading.

What would be the best way of doing this?

Zorilla
Mar 23, 2005

GOING APE SPIT

MononcQc posted:

What would be the best way of doing this?

Would this work?

code:
$('#mydiv')
.hide() // probably don't need to do this
.fadeIn()
.mouseover(function() {
	// one of these two, but not both
	$(this).show();
	// or
	$(this).fadeIn(0);
});
show() would be the cleanest way to do this, but it may get overridden by the fadeIn() that is happening at the same time. If that's the case, maybe another fadeIn set to 0 milliseconds will override the original one instead. If jQuery shits a brick for 0 milliseconds, try 1 or 10 or something.

Zorilla fucked around with this message at 21:54 on Nov 3, 2008

MononcQc
May 29, 2007

Zorilla posted:

Would this work?

code:
$('#mydiv')
.hide()
.fadeIn()
.mouseover(function() {
	// one of these two, but not both
	$(this).show();
	// or
	$(this).fadeIn(0);
});
show() would be the cleanest way to do this, but it may get overridden by the fadeIn() that is happening at the same time. If that's the case, maybe another fadeIn set to 0 milliseconds will override the original one instead. If JQuery shits a brick for 0 milliseconds, try 1 or 10 or something.
What I have is basically equivalent:
code:
$('a.someclass').bind('mouseover', function(){
	$('#mydiv').fadeIn();
	// <snip> positionning and content stuff
});
$('a.someclass').bind('mouseleave', function(){
	$('#mydiv').fadeOut();
});
$('#mydiv').bind('mouseenter', function(){
	$(this).fadeIn();
});
$('#mydiv').bind('mouseleave', function(){
	$(this).fadeOut();
});
From what I get, it does the same thing.

The fade is necessary because otherwise, moving the mouse over from the link to the div (about 10 px away) is impossible as stuff instantly disappears.

Maybe I'm thinking of it wrong, but assuming the fade is really what I need (looks nifty, too), the problem is that going this way, the actions are kind of like this:

code:
                     --- time --->
events    |--mouseenter----mouseleave-------------------------------------|
animation |--fadeOut()... ... ... ... (invisible)fadeIn()... ...(100%)----|

The css({opacity: '1'}); method just doesn't react, and having it to opacity:0 makes it flash but then it keeps going at the rate it was.

I guess there must be some other way of making things pretty and usable.

Zorilla
Mar 23, 2005

GOING APE SPIT
Unfortunately, I'm having trouble visualizing exactly what's going on, but that's my fault.

I do see that you're not using an explicit fade speed on the mouseover events, so it's probably defaulting to 400ms. I assume you want a normal speed fade-in when an element is clicked, but you want to make it instant if the element that is fading in has the cursor over it, right?

Also, you probably already know this, but you can stack your methods:

php:
<?
$('a.someclass')
.bind('mouseover', function(){
    $('#mydiv').fadeIn();
    // <snip> positionning and content stuff
})
.bind('mouseleave', function(){
    $('#mydiv').fadeOut();
});

$('#mydiv')
.bind('mouseenter', function(){
    $(this).fadeIn();
})
.bind('mouseleave', function(){
    $(this).fadeOut();
});
?>


Better yet, the hover() method is great when you need to handle both mouseover and mouseout at once. (any reason you were using Microsoft-only events like mouseenter and mouseleave?)

php:
<?
$('a.someclass').hover(
    function() {
        $('#mydiv').fadeIn();
        // <snip> positionning and content stuff
    },
    function() {
        $('#mydiv').fadeOut();
    }
);

$('#mydiv').hover(
    function() {
        $(this).fadeIn();
    },
    function() {
        $(this).fadeOut();
    }
);
?>


edit: I think I see what you're talking about. If you move your mouse back and forth over the blue links on the jQuery's documentation for hover(), you can see each event just queues up instead of interrupting each other.

Zorilla fucked around with this message at 22:03 on Nov 3, 2008

MononcQc
May 29, 2007

Zorilla posted:

edit: I think I see what you're talking about. If you move your mouse back and forth over the blue links on the jQuery's documentation for hover(), you can see each event just queues up instead of interrupting each other.

Exactly, that's the problem.

I'd like to be able to interrupt the animations, which seems impossible to do.

I guess I'll have to make my own fading system with the css opacity property. That's pretty bad.

Zorilla
Mar 23, 2005

GOING APE SPIT

MononcQc posted:

I'd like to be able to interrupt the animations, which seems impossible to do.

I just found this:

http://docs.jquery.com/Effects/stop

Sounds like just what you were looking for. Try putting $(this).stop().show() (or fadeIn(0), whatever works) on your mouseout events and see what happens.

Zorilla fucked around with this message at 22:11 on Nov 3, 2008

MononcQc
May 29, 2007

Zorilla posted:

I just found this:

http://docs.jquery.com/Effects/stop

Sounds like just what you were looking for. Try putting $(this).stop().show() (or fadeIn(0), whatever works) on your mouseout events and see what happens.

Doesn't work too well with fadeIn and fadeOut, but with animate({opacity:'x'},time), it works fine! Thanks!

Zorilla
Mar 23, 2005

GOING APE SPIT

MononcQc posted:

Doesn't work too well with fadeIn and fadeOut, but with animate({opacity:'x'},time), it works fine! Thanks!

Does that work cross-browser? If not, you may want to also animate filter: alpha(opacity='x') as well (where x goes from 0 to 100) just to make sure things work in IE.

Also, this looks even better:

http://docs.jquery.com/Effects/dequeue

Zorilla fucked around with this message at 22:44 on Nov 3, 2008

epswing
Nov 4, 2003

Soiled Meat
So you got it working? I'd be interested in this, can you post a working example?

MononcQc
May 29, 2007

epswing posted:

So you got it working? I'd be interested in this, can you post a working example?
Eh, it should work there, if I didn't forget to move crap: http://parseidon.com/test/demo.html

IE still fucks up sometimes, but the way it does is completely acceptable to me.
I don't exactly get why fadeIn() and fadeOut() wouldn't cooperate with stop, but eh, animate() did it.

--

Zorilla, alpha(opacity='x') is not necessary. You can find this bit of code in the jQuery source:

code:
if ( msie && name == "opacity" ) {
	if ( set ) {
		// IE has trouble with opacity if it does not have layout
		// Force it by setting the zoom level
		elem.zoom = 1;

		// Set the alpha filter to set the opacity
		elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
			(parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
	}

	return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
		(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
		"";
}
jQuery automatically detects if you use opacity and if you're in IE it then translates it to alpha for you, and even makes sure hasLayout kicks in so it works.

sonic bed head
Dec 18, 2003

this is naturual, baby!
I have a bit of code in jQuery that isn't working as I expect at all.

code:

$(function(){
			$("#mainCategories").empty()
			var oldOne = false;
			jQuery.each(mainCats,function(i,val){
				$("#mainCategories").append("<div class=\"mainCats\">"+val+"</div>")

				$(".mainCats").click(function(){
						if(oldOne){console.log(oldOne);

								$(oldOne).animate({
										height:"20px"
									
									})
							}
						
						$(this).animate({
								height:"50px"
							});
						oldOne = this;
					})
			})
		})

I'm expecting this to on the first click of a main category, make it 50px and then on subsequent clicks, close the previous one, and then continue making the newly clicked one 50px. For some reason when I try this code, it just bounces the first click up and down - from 50 to 20px. Also, I don't understand why I am only logging the clicked div rather nothing being logged because it should never enter that line. What am I doing incorrectly here?

Zorilla
Mar 23, 2005

GOING APE SPIT

sonic bed head posted:

I'm expecting this to on the first click of a main category, make it 50px and then on subsequent clicks, close the previous one, and then continue making the newly clicked one 50px. For some reason when I try this code, it just bounces the first click up and down - from 50 to 20px. Also, I don't understand why I am only logging the clicked div rather nothing being logged because it should never enter that line. What am I doing incorrectly here?

I don't know the exact details of this, but maybe the $(this).animate({height: "50px"}); line needs to be inside an else portion of the if statement? In its current state, it looks like it runs no matter what. How about this:

php:
<?
$(function(){
    $("#mainCategories").empty();
    var oldOne = false;
    
    jQuery.each(mainCats, function(i, val) {
        $("#mainCategories").append("<div class=\"mainCats\">"+val+"</div>");
        
        $(".mainCats").click(function() {
            if (this != oldOne) {
                // First click
                $(this).animate({height: "50px"});
                oldOne = this;
            } else {
                // Subsequent clicks
                console.log("oldOne: "+oldOne);
                $(oldOne).animate({height: "20px"});
            }
        });
    });
});
?>

(edit: that solution was likely wrong. It probably should have looked like this: )
php:
<?
$(function(){
    $('#mainCategories').empty();
    var oldOne = false;
    
    jQuery.each(mainCats, function(i, val) {
        $('#mainCategories').append('<div class="mainCats">'+val+'</div>');
    });
    
    $('.mainCats').click(function() {
        $(this).animate('height', '50px');
        if (oldOne) $(oldOne).animate('height', '20px');
        oldOne = this;
    });
});
?>

Zorilla fucked around with this message at 23:58 on Nov 14, 2008

sonic bed head
Dec 18, 2003

this is naturual, baby!

Zorilla posted:

I don't know the exact details of this, but maybe the $(this).animate({height: "50px"}); line needs to be inside an else portion of the if statement? In its current state, it looks like it runs no matter what. How about this:

php:
<?
$(function(){
    $("#mainCategories").empty();
    
    jQuery.each(mainCats, function(i, val) {
        $("#mainCategories").append("<div class=\"mainCats\">"+val+"</div>")
        
        $(".mainCats").click(function() {
            if (this.oldOne == false) {
                // First click
                $(this).animate({height: "50px"});
                var this.oldOne = true;
            } else {
                // Subsequent clicks
                console.log("oldOne: "+oldOne);
                $(oldOne).animate({height: "20px"});
            }
        });
    });
});
?>

Ah! I figured it out. Only after seeing you clean up my code did I think about it.

I'm attaching those event handlers inside a .each loop. so it is getting added ~20 times for each .mainCats div. Thank you, it's all fixed now

Zorilla
Mar 23, 2005

GOING APE SPIT
Cool- I screwed up a line or two, so don't expect it to work right away (the part where I wrote this.oldOne was totally wrong)

edit: actually, my whole thing was probably wrong. Oh well, it's fixed by now anyway.

Zorilla fucked around with this message at 21:02 on Nov 14, 2008

nbv4
Aug 21, 2002

by Duchess Gummybuns
I guess this is more of an xpath thing, but how can locate all anchor elements where the href is blank?

code:
$("a[@href*=''").click(function(event) {
	event.preventDefault();
});

Zorilla
Mar 23, 2005

GOING APE SPIT

nbv4 posted:

I guess this is more of an xpath thing, but how can locate all anchor elements where the href is blank?

code:
$("a[@href*=''").click(function(event) {
	event.preventDefault();
});

As far as I know, XPath and CSS3 selectors (what jQuery uses) use totally separate syntaxes, even if they look really similar. You probably want $('a[href=""'])

Zorilla fucked around with this message at 20:17 on Nov 27, 2008

nbv4
Aug 21, 2002

by Duchess Gummybuns
^^ before I had my links as "<span class="fake_anchor" onclick="[blah]">text</span>" but once I found jQuery, I changed all the "fake anchors" to anchors, but for some dumb reason, forgot to change the <\span>'s to </a>'s. Oops.

New question:

code:
function fire_popup() {						//creates the popup

	top = (window.innerHeight - $('#popup').innerHeight()) / 2;
	left = (window.innerWidth - $('#popup').innerWidth()) / 2;
	
	$('#popup').draggable({ 
		zIndex: 20,
		cursor: 'move',
		opacity: 1.0,
		handle: '#dragbar'
	}).css("top", top).css("left", left).show();
}
This function turns #popup, a div thats originally set to "display: none; position: absolute", makes it draggable, and then centers it onto the webpage. It works like a charm all except for when the user is scrolled down the page some. I want to make it so if the user has the page scrolled down 50 pixels, it moves the popup down another 50 pixels. How can I do this?

Also, I kind of accidentally stumbled onto innerHeight(). Is this a jQuery function and therefore cross broswer, or a javascript function and therefore non cross browser? I can't find it documented anywhere. I know there is an attribute called innerHeight (which most definitely not cross browser supported), but not the function...

sonic bed head
Dec 18, 2003

this is naturual, baby!

nbv4 posted:

^^ before I had my links as "<span class="fake_anchor" onclick="[blah]">text</span>" but once I found jQuery, I changed all the "fake anchors" to anchors, but for some dumb reason, forgot to change the <\span>'s to </a>'s. Oops.

New question:

code:
function fire_popup() {						//creates the popup

	top = (window.innerHeight - $('#popup').innerHeight()) / 2;
	left = (window.innerWidth - $('#popup').innerWidth()) / 2;
	
	$('#popup').draggable({ 
		zIndex: 20,
		cursor: 'move',
		opacity: 1.0,
		handle: '#dragbar'
	}).css("top", top).css("left", left).show();
}
This function turns #popup, a div thats originally set to "display: none; position: absolute", makes it draggable, and then centers it onto the webpage. It works like a charm all except for when the user is scrolled down the page some. I want to make it so if the user has the page scrolled down 50 pixels, it moves the popup down another 50 pixels. How can I do this?

Also, I kind of accidentally stumbled onto innerHeight(). Is this a jQuery function and therefore cross broswer, or a javascript function and therefore non cross browser? I can't find it documented anywhere. I know there is an attribute called innerHeight (which most definitely not cross browser supported), but not the function...

It is definitely a jQuery function. I can't find the documentation either but here's the source:

code:
jQuery.each([ "Height", "Width" ], function(i, name){

	var tl = i ? "Left"  : "Top",  // top or left
		br = i ? "Right" : "Bottom"; // bottom or right

	// innerHeight and innerWidth
	jQuery.fn["inner" + name] = function(){
		return this[ name.toLowerCase() ]() +
			num(this, "padding" + tl) +
			num(this, "padding" + br);
	};

	// outerHeight and outerWidth
	jQuery.fn["outer" + name] = function(margin) {
		return this["inner" + name]() +
			num(this, "border" + tl + "Width") +
			num(this, "border" + br + "Width") +
			(margin ?
				num(this, "margin" + tl) + num(this, "margin" + br) : 0);
	};

});

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

sonic bed head posted:

It is definitely a jQuery function. I can't find the documentation either but here's the source:


It's in the CSS section: http://docs.jquery.com/CSS

code:
innerHeight( )

Overview

Gets the inner height (excludes the border and includes the padding) for the first matched element.
This method works for both visible and hidden elements.

Dromio
Oct 16, 2002
Sleeper
Any ideas on a good way to animate a growing border around a positioned div? I've got an absolutely positioned div on my page that I want to "highlight" for the user if they cannot find it. I wanted to do this by drawing a red border around it that grows/shrinks to draw their eye. But since the border is included "inside" the div rectangle, the text ends up moving down/right to accommodate the growing border.

Is there an easy way to handle this that I'm missing?

Zorilla
Mar 23, 2005

GOING APE SPIT

Dromio posted:

Any ideas on a good way to animate a growing border around a positioned div? I've got an absolutely positioned div on my page that I want to "highlight" for the user if they cannot find it. I wanted to do this by drawing a red border around it that grows/shrinks to draw their eye. But since the border is included "inside" the div rectangle, the text ends up moving down/right to accommodate the growing border.

Is there an easy way to handle this that I'm missing?

Borders, padding, and margins aren't included in the width and height definitions of a block element. This means that, given a box with a constant 300px width, it will still get bigger if the border gets thicker, pushing everything inside down and to the right.

You might try animating the width and height of the box down the same number of pixels the border thickens to. I don't know if that will end up looking jumpy or jerky though.

Dromio
Oct 16, 2002
Sleeper

Zorilla posted:

Borders, padding, and margins aren't included in the width and height definitions of a block element. This means that, given a box with a constant 300px width, it will still get bigger if the border gets thicker, pushing everything inside down and to the right.
Yes, this is my problem exactly. I tried animating the position AND border size at the same time, but like you said, it ended up looking kind of jumpy.

I think I'll just have to come up with another method of highlighting the area.

LOLLERZ
Dec 9, 2003
ASK ME ABOUT SPAMMING THE REPORT FORUM TO PROTECT ~MY WIFE'S~ OKCUPID PERSONALS ANALYSIS SA-MART THREAD. DO IT. ALL THE TIME. CONSTANTLY. IF SHE DOESN'T HAVE THE THREAD, SHE'LL WANT TO TALK TO ME!

Dromio posted:

Yes, this is my problem exactly. I tried animating the position AND border size at the same time, but like you said, it ended up looking kind of jumpy.

I think I'll just have to come up with another method of highlighting the area.
You could use something like this http://www.usabilitypost.com/2008/11/27/scalable-content-box-using-only-one-background-image/ to make a border around your box and have another :hover version that uses an animated gif/png as the border.

Gone Fission
Apr 7, 2007

We're here to make coffee metal. We're here to make everything metal.
I've used some of the jQuery plugins and they've worked well for me.

The validation plugin is a pretty nice way to validate user input on a form. Here's an example of it in use.

Gone Fission fucked around with this message at 20:46 on Jan 8, 2009

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
This is probably painfully obvious, but I want to run a function I have defined elsewhere in my code after a jQuery chain is done. How do I do that?

currently:
code:
jQuery('#someEl').empty();
myFunction();
myFunction is getting a called before #someEl is empty, and empty() does not have a callback, so how do I do something like:

code:
jQuery('#someEl').empty().myFunction();

KuruMonkey
Jul 23, 2004

Lumpy posted:

This is probably painfully obvious, but I want to run a function I have defined elsewhere in my code after a jQuery chain is done. How do I do that?

You want to be writing a plugin to jQuery, which is as simple as:

[code]
jQuery.myFunction = function()
{
// your code here
return jQuery; // this maintains chaining
};
[/php]

http://docs.jquery.com/Plugins/Authoring for their docs

then jQuery('#someEl').empty().myFunction(); will work, and so will jQuery.myFunction().hide(); etc

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

KuruMonkey posted:

You want to be writing a plugin to jQuery, which is as simple as:

http://docs.jquery.com/Plugins/Authoring for their docs

then jQuery('#someEl').empty().myFunction(); will work, and so will jQuery.myFunction().hide(); etc

Thanks, I knew it would be something simple :)

Pardot
Jul 25, 2001




This is pretty cool, it does the whole default text that disappears when you click it. It also has it in the background that text will never get submitted to you: http://github.com/hpoydar/jquery-form-prompt/tree/master

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Pardot posted:

This is pretty cool, it does the whole default text that disappears when you click it. It also has it in the background that text will never get submitted to you: http://github.com/hpoydar/jquery-form-prompt/tree/master

From it's documentation:

quote:

Seemingly populate form inputs with text that disappears when the field is focussed. Works by not actually modifying the form field at all, instead an overlay div with the prompt text is added to the DOM. This approach works better than direct form field modification with AJAX-submitted forms and components.
Pretty cool, but why exactly is an overlay better than direct form field modification with AJAX-submitted forms?

Warbling Castrato
Sep 25, 2003

I'm completely stuck with a Cluetip issue.

Ive set activation to 'click' and sticky to 'true'. But I want to make it so that if another Cluetip link is clicked whilst one is already open, it will close the current one and open the new one that the user has clicked.

I hope that made sense. Essentially, can I close open Cluetips when the user clicks to open another one? It only seems to close the currently open one if activation is set to hover.

My set up is as follows:

code:
$(document).ready(function() {
  $('a.tip').cluetip({activation: 'click', sticky: true});
});
Cheers

EDIT: gently caress, never mind, it looks like there was some corruption in the ClueTip file. All fixed now.

Warbling Castrato fucked around with this message at 12:40 on Jan 22, 2009

Adbot
ADBOT LOVES YOU

SuckerPunched
Dec 20, 2006

supster posted:

From it's documentation:

Pretty cool, but why exactly is an overlay better than direct form field modification with AJAX-submitted forms?

I'm guessing because you're not messing with the form fields themselves, which eliminates the possibility of someone submitting the "example" text unless they manually type it in.

  • Locked thread