[jQuery] Safari 4 with jQuery/Json - anyone experience problems?

2009-09-16 Thread MiKiTiE

Hi everyone

I've been working on an ajax call which activates a spellchecker when
someone inputs a word (if it's incorrect) and returns a Json string of
suggestions for the user to choose from, and then be able to replace
the incorrect word.

It seems to work the first couple of times but then Safari will hang
and finally quit. I'm not sure what I've done wrong, but for some
reason the console on FF doesn't register the call so I'm assuming
something else is causing a problem - unless there's a compatibility
issue with jQuery on Safari 4.

Here's my function that calls the spellchecker (Sorry it's a bit
long!)


/**/

var SpellCheckOptions = { learn : false, serverScriptURL :
'spellchecker.php' };

function checkSpelling(type,targetId,exists,len,ulen) {
var theid = "#"+targetId;
var $spellcheckthis = $(theid);
var thetext = $spellcheckthis.text();

var callback = function(textInfos) {
if(type=="textarea"){
$("form")[0].reset(); // reset textarea content before 
populating it
with the edited text
}
  $spellcheckthis.text(textInfos[0].text);
if(type=="word"){ // if we're spell checking a word/phrase
if(exists == false){ // if that word doesn't exist in the
userwords array

if(len<6){

words[targetId][1].push(textInfos[0].text);

var userwordexists = false;
for(var u=0;u

[jQuery] Re: Get the onclick method of an element

2009-09-15 Thread MiKiTiE

Ok, I've done some tests and here is my suggestion.

First of all, should just ask - I assume you are calling it after the
element? Probably is obvious, but thought I'd check.

Ok, here's the deal: "onclick" is not really an attribute but a mouse
event. Therefore jQuery will take the contents as a function and write
it out as an event. The only alternative is to insert your "DoSomething
(this);" into a standard attribute like "title" or "alt" and then take
it from there. This way you should be able to insert it exactly as its
written and not have it converted into an event.

Hope this will help?

On Sep 15, 2:31 pm, sirrocco  wrote:
> >Perhaps then you can extract it as text like I mentioned in my first
>
> post, then store it in a variable?
>
> How do I extract it like text ? Calling the .text() method, as
> expected doesn't return what I need - DoSomething(this);
>
> On Sep 15, 3:30 pm,MiKiTiE wrote:
>
> > Perhaps then you can extract it as text like I mentioned in my first
> > post, then store it in a variable?
>
> > As I am not sure what your function does or why it needs to be applied
> > this way, I can't solve the problem exactly - but why not just use an
> > event instead of an onclick in the element? That is what jQuery is
> > there for :-)
>
> > On Sep 15, 9:50 am, sirrocco  wrote:
>
> > > Well .. that's the problem - i tried it like that and it didn't work.
>
> > > When setting the attribute back on the link, the this in DoSomething
> > > (this); is not the link, but the window.
>
> > > On Sep 15, 11:41 am,MiKiTiE wrote:
>
> > > > Sorry I should have written
>
> > > > $('a').attr('onclick',onclick);
>
> > > > (setting the attribute value not the inner text!)
>
> > > > On Sep 15, 9:09 am, sirrocco  wrote:
>
> > > > > Let's say you have a :
>
> > > > > asd
>
> > > > > I want to get the onclick text in a variable - something like
>
> > > > > var onclick = $('a').attr('onclick');
>
> > > > > The problem is that the onclick variable now is a function and if I
> > > > > try to execute , this   wil be the document instead of the link .
>
> > > > > How can I get only the text, so I can later reattach it to the link ?


[jQuery] Re: Jquery gradient and tabs

2009-09-15 Thread MiKiTiE

Ah, since I am not familiar with this implementation of tabs (only the
jQuery built in one) I'm not sure I know the answer, sorry. Have you
contacted the creator of those tabs?

On Sep 15, 1:38 pm, Anush Shetty  wrote:
> On Tue, Sep 15, 2009 at 5:55 PM,MiKiTiE wrote:
>
> > Having checked the source code, it looks like you're not even
> > including the core and tabs ui.
>
> > For example:
>
> > http://jqueryui.com/latest/ui/</a>
> > ui.core.js">
> > http://jqueryui.com/latest/ui/</a>
> > ui.tabs.js">
>
> > If you were to link direct to jquery. That may be why your tabs are
> > not working properly.
>
> No, its not that. I am using this technique
>
> http://blueprintcss.org/demos/tabs.html
>
> This doesn't need ui.core.js and ui.tabs.js
>
> -
> Anush


[jQuery] Re: Get the onclick method of an element

2009-09-15 Thread MiKiTiE

Perhaps then you can extract it as text like I mentioned in my first
post, then store it in a variable?

As I am not sure what your function does or why it needs to be applied
this way, I can't solve the problem exactly - but why not just use an
event instead of an onclick in the element? That is what jQuery is
there for :-)

On Sep 15, 9:50 am, sirrocco  wrote:
> Well .. that's the problem - i tried it like that and it didn't work.
>
> When setting the attribute back on the link, the this in DoSomething
> (this); is not the link, but the window.
>
> On Sep 15, 11:41 am,MiKiTiE wrote:
>
> > Sorry I should have written
>
> > $('a').attr('onclick',onclick);
>
> > (setting the attribute value not the inner text!)
>
> > On Sep 15, 9:09 am, sirrocco  wrote:
>
> > > Let's say you have a :
>
> > > asd
>
> > > I want to get the onclick text in a variable - something like
>
> > > var onclick = $('a').attr('onclick');
>
> > > The problem is that the onclick variable now is a function and if I
> > > try to execute , this   wil be the document instead of the link .
>
> > > How can I get only the text, so I can later reattach it to the link ?


[jQuery] Re: Jquery gradient and tabs

2009-09-15 Thread MiKiTiE

Having checked the source code, it looks like you're not even
including the core and tabs ui.

For example:

http://jqueryui.com/latest/ui/</a>
ui.core.js">
http://jqueryui.com/latest/ui/</a>
ui.tabs.js">

If you were to link direct to jquery. That may be why your tabs are
not working properly.

On Sep 15, 12:15 pm, anush  wrote:
> On Sep 14, 3:58 pm, MiKiTiE  wrote:
>
> > Could you provide a link?
>
> http://wildindia.org/mwtest/grad.php
>
> If you see the there, the Tab #2 is inactive.
>
> -
> Anush


[jQuery] Re: Get the onclick method of an element

2009-09-15 Thread MiKiTiE

Sorry I should have written

$('a').attr('onclick',onclick);

(setting the attribute value not the inner text!)

On Sep 15, 9:09 am, sirrocco  wrote:
> Let's say you have a :
>
> asd
>
> I want to get the onclick text in a variable - something like
>
> var onclick = $('a').attr('onclick');
>
> The problem is that the onclick variable now is a function and if I
> try to execute , this   wil be the document instead of the link .
>
> How can I get only the text, so I can later reattach it to the link ?


[jQuery] Re: Get the onclick method of an element

2009-09-15 Thread MiKiTiE

You will need to use the text() attribute to do this.

so, once you do:

var onclick = $('a').attr('onclick');

You then place it where you want this way:

$("a").text(onclick);

However, if you have several links on a page it will be better to
assign it to an id. Plus, since "onclick" is a javascript handler I'm
thinking it may be better to use a different phrase as your variable
to avoid confliction.

Mike


On Sep 15, 9:09 am, sirrocco  wrote:
> Let's say you have a :
>
> asd
>
> I want to get the onclick text in a variable - something like
>
> var onclick = $('a').attr('onclick');
>
> The problem is that the onclick variable now is a function and if I
> try to execute , this   wil be the document instead of the link .
>
> How can I get only the text, so I can later reattach it to the link ?


[jQuery] Re: Flipv Vertical Text and extra space

2009-09-14 Thread MiKiTiE

Flipv only supports Verdana font fully, is this the font you're using?

Also, do you have a link to your code, and which browsers are causing
problems?

Mike

On Sep 14, 11:24 am, Paul Collins  wrote:
> Hi all
>
> I'm currently using the Jquery Flipv plugin, which works well. The only
> problem is, some words have extra padding at the end, depending on how many
> characters.http://www.openstudio.fr/jQuery-flipv.html?lang=en
>
> I'm not sure why this is, but it seems that the conversion to vertical text
> creates some extra spacing on certain browsers. Can anyone tell me why this
> is? I'm trying to get advice through the site, but it's all in French and I
> can't understand it!
>
> Thanks for any help


[jQuery] Re: Flipv Vertical Text and extra space

2009-09-14 Thread MiKiTiE

Oh, and also - there's a little drop down box in the top right corner
which will allow you to change the language to English :-)

On Sep 14, 11:24 am, Paul Collins  wrote:
> Hi all
>
> I'm currently using the Jquery Flipv plugin, which works well. The only
> problem is, some words have extra padding at the end, depending on how many
> characters.http://www.openstudio.fr/jQuery-flipv.html?lang=en
>
> I'm not sure why this is, but it seems that the conversion to vertical text
> creates some extra spacing on certain browsers. Can anyone tell me why this
> is? I'm trying to get advice through the site, but it's all in French and I
> can't understand it!
>
> Thanks for any help


[jQuery] 'key' related events throw up warnings in FF

2009-09-14 Thread MiKiTiE

Hi everyone

Everytime I try to use a keyup/keypress/keydown event in my code, I
get a warning in my Firebug whenever it is fired:

>> The 'charCode' property of a keydown event should not be used. The value is 
>> meaningless.

I'm not quite sure what this means, but I'm guessing it's because I
have not set the value of a particular key - however, this is not
required for my function which basically just makes a button appear
when the user puts text in an input field.

My function:

$(function() {
$("#myinput").keyup(function() {
var theval = $("#myinput").val();
var mybutton = $("#thebutton");
if(theval!=""){
mybutton.fadeIn(200);
}else{
mybutton.fadeOut(200);
}
});
});

Which seems to actually word - except I get the warning above. Does
anyone know how to avoid this happening?

Thanks,
Mike


[jQuery] Re: Browser Stop call's ajax.Error

2009-09-14 Thread MiKiTiE

Probably because you're sending the data to the url, but stopping the
process before it can produce a result.

On Sep 13, 7:52 pm, "nirazue...@gmail.com" 
wrote:
> Hi, I've noticed that when I click the Stop button on the browser, or
> navigate to another page, jQuery.ajax calls the error event.
>
> You can see the problem live at:http://www.pingmyport.com/
>
> Code:
>
>    this.getJson = function(timeout) {
>       if(this.XMLHttpRequest) this.XMLHttpRequest.abort();
>       this.XMLHttpRequest = $.ajax({
>          complete: function(){$("#kitLoader").hide();},
>          data: {
>             Address: him.Address,
>             portNum: him.portNum,
>             portType: him.portType
>          },
>          dataType: "json",
>          error: him.serviceUnavailable,
>          success: him.processJson,
>          timeout: timeout,
>          type: "POST",
>          url: "http://www.pingmyport.com/checkPort.php";
>       });
>    };


[jQuery] Re: Removal of element before body

2009-09-14 Thread MiKiTiE

To remove them you could use

$(function() {
   $("br").remove();
});

but to find where they are is more difficult, as you could end up
removing key elements like the  tag itself. If it's placing it
where you don't want it to, maybe the script needs tweaking? Could you
possibly post it here, or even a link would be better? That would
enable me to help you a bit easier.

Mike


However in order to detect where they are in the document is more
difficult.

On Sep 14, 12:43 pm, paulswansea  wrote:
> Hi,
>
> How can I remove an element before the body of the document, the long
> and the short of it is that a script I use places a  statement
> (amongst other things) dynamically into my web pages and based upon
> which browser I use, sometimes it places it inside the  and
> sometimes places it before the  and in some browsers not at all.
> I know it shouldn't, but it does.
>
> So basically, is there a way of removing the br statement if it exists
> before the body element?


[jQuery] Re: Jquery gradient and tabs

2009-09-14 Thread MiKiTiE

Could you provide a link?

On Sep 14, 3:38 am, Anush Shetty  wrote:
> When I try using jquery gradient plugin with tabs, I see that the tabs
> get disabled.
>
> Does anybody here know the reason behind it ?
>
> --
> Anush


[jQuery] How to unbind data?

2009-09-04 Thread MiKiTiE

Hi everyone

I'm trying to write a function that will pass through the id of a
clicked element, and then use that id for spellchecking the word
that's been clicked on. However, although this seems to work, when i
click on another word, it returns the previous corrected word rather
than the new one - as if it's storing the same data all the time. I
was advised to unbind the event but that doesn't seem to work...

Here is my code - but let me quickly explain. First off, there is a
div with text in which has several "clickable" words which can be
altered by the user by means of a pop up tooltip with input box. If
the user types a word in and hits "save", the spell check will
activate (i.e. checkWordSpelling). I'm firstly unbinding the click
event, and then rebinding it for the next word - and although the
correct id is detected, the word that it's supposed to place there
after correcting is always the same one (i.e. the first one that was
corrected):

$('#'+tooltipsavebtn).unbind('click');

$('#'+tooltipsavebtn).bind("click",{theid: id },function(e) {

var newval = $('#'+tooltipinput).val();
setProfileText(id,newval,tooltipid,targetid);
spellchecked = false;
pickedfromlist = false;

checkWordSpelling(e.data.theid);

var exists = false;
for(i=0;i

[jQuery] Re: Help with using the 'not' selector

2009-08-24 Thread MiKiTiE

Thanks for your help but this is still not working. All that happens
is as soon as I click the word to make the div appear, it fades out
again.

I'm probably being totally thick here and missing something really
simple but I just cannot figure it out. All I need is for the div to
appear when clicking the link and to disappear when clicking out of
it.

This is how I make it appear:

$('a').click(function(e){
var x = $('#FM_OPTIONS').css( {
'left' : e.pageX - 100,
'top' : e.pageY + 35
} );

x.show();
});

which works.

I tried just a simple test:

$('body').click(function(){
$("#FM_OPTIONS").fadeOut('fast');
});

and even that doesn't do anything. I tried implementing the :not()
selector by saying "if it's not an  tag" but I don't think that's
what it's actually for. I hope someone can come up with a working
solution - I would really appreciate it.

Thanks.


On Aug 17, 8:18 pm, Ricardo  wrote:
> return false; in your 's click handler should avoid that, as it
> prevents the event from bubbling to the body. You can also check
> visibility:
>
> $().click(function(){
>     var opt = $(#'fm_options');
>     if( this != opt[0] && opt.is(':visible') )
>       opt.fadeOut('fast');
>
> });
>
> On Aug 17, 6:27 am,MiKiTiE wrote:
>
> > Thanks for your reply.
>
> > This is pretty much what I want - except I need my div to appear when
> > a particular link is clicked, but since I've put the fire in the body,
> > it's basically doing the fadeOut on every click (which stands to
> > reason since everything is the body!) So really what I need is
> > something else in there that says if it's also NOT an  tag...but
> > I'm pretty sure that if the  tag is clicked it will recognise it as
> > the body still? Is there some kind of work around for this?
>
> > Thanks
> > Mike
>
> > On Aug 14, 5:42 pm, Wolf  wrote:
>
> > > hi you have ask if the id is different, then dissappear the div o
> > > element
>
> > > $("body").click(function(){
> > >     IF($(this).attr('id') !="FM_OPTIONS")
> > >     {
> > >       $("#FM_OPTIONS").fadeOut('fast');
> > >     }
>
> > > });


[jQuery] Re: Help with using the 'not' selector

2009-08-17 Thread MiKiTiE

Thanks for your reply.

This is pretty much what I want - except I need my div to appear when
a particular link is clicked, but since I've put the fire in the body,
it's basically doing the fadeOut on every click (which stands to
reason since everything is the body!) So really what I need is
something else in there that says if it's also NOT an  tag...but
I'm pretty sure that if the  tag is clicked it will recognise it as
the body still? Is there some kind of work around for this?

Thanks
Mike

On Aug 14, 5:42 pm, Wolf  wrote:
> hi you have ask if the id is different, then dissappear the div o
> element
>
> $("body").click(function(){
>     IF($(this).attr('id') !="FM_OPTIONS")
>     {
>       $("#FM_OPTIONS").fadeOut('fast');
>     }
>
> });


[jQuery] Re: Replace string characters using jQuery

2009-08-14 Thread MiKiTiE

Thank you for your help. The global flag seemed to do the trick, if I
get problems with that in the future I will try the encodeURIComponent
method.



On Aug 5, 9:42 pm, Karl Swedberg  wrote:
> Hi there,
>
> It looks like your test:
>
> > var test = searchval.text().replace(' ','+');
>
> is trying to use the .text() jQuery method on a string. Remove that  
> part and it should work, sort of. It'll only replace the first  
> instance of a space. Instead, use the regex replace and set the global  
> (g) flag:
>
>         var test = searchval.replace(/ /g,'+')
>
> But that isn't much better. What you really ought to use is  
> encodeURIComponent:
>
>         var test = encodeURIComponent(searchval);
> see how that works.
>
> --Karl
>
> ____
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Aug 5, 2009, at 5:00 AM, MiKiTiE wrote:
>
>
>
> > Hi Everyone
>
> > First post - please be gentle.
>
> > I am running a search on my web site which uses jQuery to take the
> > search terms and build up a URL based on them.
>
> > For example, if someone searches for "chair" my URL will be appended
> > with /chair/.
>
> > However, if someone searches for something which is two words, for
> > example "chair covers" I need the space inbetween to be replaced by a
> > "+" sign so the URL will now be appended with /chair+covers/
>
> > I'm not sure if it is possible to string replace in jQuery? Here is my
> > current code:
>
> > function sendSearchInput(whichelement,hiddeninput,formid) {
>
> > hval = $("#"+hiddeninput).val();
> > $("#"+formid).submit(function() {
> >    if ($("input:#"+whichelement).val() != hval) {
>
> >            var searchval = $("#"+whichelement).val().toLowerCase();
>
> >            $("#"+formid).attr("action","retail/search/"+searchval+"/");
> >                    return true;
> >            }
>
> >              $("input:#"+whichelement).focus();
>
> >      return false;
> >    });
> > }
>
> > This will basically check that the form is not the default value
> > (specified in the hidden field "hval") and then change the search term
> > to lowercase and append the URK using "attr". I have tried a couple of
> > methods including
>
> > var test = searchval.text().replace(' ','+');
>
> > And then trying to alert "test" to check it but the function just
> > simply doesn't work.
>
> > Any help here would be much appreciated, thank you.


[jQuery] Help with using the 'not' selector

2009-08-14 Thread MiKiTiE

Hi group,

I would appreciate a point in the right direction here, as I seem to
be getting lost. I would like to be able to write a function which
will trigger when the mouse is clicked, but only do a certain thing
based on WHAT is clicked. Which is why I figured the "not" selector
would be useful.

Here is my function:

function closeIt(){
 $().not("#FM_OPTIONS").click( function() {
$("#FM_OPTIONS").toggle();
});
}

Basically what I want to say is, if what I click does NOT have the id
'#FM_OPTIONS' (it's a floating div), make that div disappear. In other
words, if someone clicks away from it, it should close. However it
seems that even if I click the div itself, it makes it disappear as
well - surely the 'not' selector is supposed to prevent this? Am I
structuring the function incorrectly? Any help would be much
appreciated.

Thank you.
Mike


[jQuery] Re: Live function being weird

2009-08-05 Thread MiKiTiE

If I remember correctly the live event can only handle tag elements
not specific names. So for example, $("form").live('click', function
() { }); would work. Perhaps you can use an id on your form, maybe
that would work? Do you have to use the live event specifically or
were you just curious as to why it won't work the same way?

On Aug 5, 9:44 am, Jaggi  wrote:
> I have two snippets of code:
>
> This one doesn't work
>
> $("form[name='edit']").live('click', function() {
>         return false;
>
> });
>
> This one does:
>
> $("form[name='edit']").click( function() {
>         return false;
>
> });
>
> I'm not sure why this is though, are attribute filters not supported
> with the live functions?


[jQuery] Replace string characters using jQuery

2009-08-05 Thread MiKiTiE

Hi Everyone

First post - please be gentle.

I am running a search on my web site which uses jQuery to take the
search terms and build up a URL based on them.

For example, if someone searches for "chair" my URL will be appended
with /chair/.

However, if someone searches for something which is two words, for
example "chair covers" I need the space inbetween to be replaced by a
"+" sign so the URL will now be appended with /chair+covers/

I'm not sure if it is possible to string replace in jQuery? Here is my
current code:

function sendSearchInput(whichelement,hiddeninput,formid) {

hval = $("#"+hiddeninput).val();
$("#"+formid).submit(function() {
if ($("input:#"+whichelement).val() != hval) {

var searchval = $("#"+whichelement).val().toLowerCase();

$("#"+formid).attr("action","retail/search/"+searchval+"/");
return true;
}

  $("input:#"+whichelement).focus();

  return false;
});
}

This will basically check that the form is not the default value
(specified in the hidden field "hval") and then change the search term
to lowercase and append the URK using "attr". I have tried a couple of
methods including

var test = searchval.text().replace(' ','+');

And then trying to alert "test" to check it but the function just
simply doesn't work.

Any help here would be much appreciated, thank you.