[jQuery] unknown pseudo-class or pseudo-element

2009-11-25 Thread Miloš Rašić
Is there a solution to the "unknown pseudo-class or pseudo-element"
error when using : selectors (like :visible, :first, :animated, :odd,
etc) in 1.3.2 yet? It generates only a warning in FF3.5 but it seems
to generate an error in IE8.


[jQuery] Re: Manipulate href

2009-08-18 Thread Miloš Rašić

You need the each() method because you are modifying each href to a
new value that depends on an old value. In order to do this, you need
to somehow retrieve the old value and for this you need the $(this)
pointer which is only available in the context of methods like each().

2009/8/17 knal :
>
> Thanks a lot, both of you! Of course now it looks really simple, but i
> couldn't fugure it out.
> What i don't get is why i need the 'each' part, because so far, with
> jQuery i would've just used
>
> #my_list a
>
> which i thought would also affect all a's in #my_list right?
>
> Thanks again!
>
> On 17 aug, 21:19, Leonardo K  wrote:
>> $("#my_list a").each(function(){
>>     newhref = '#' + $(this).attr('href').split("/")[3];
>>     $(this).attr('href', newhref);
>>   });
>>
>> On Mon, Aug 17, 2009 at 16:07, knal  wrote:
>>
>> > Hi group,
>>
>> > I'm looking for a correct way of manipulating > > The code looks like this:
>>
>> > 
>> >  Animals
>> >  Buildings
>> >  Cars
>> >  People
>> > 
>>
>> > and with jQuery i want to manipulate it into this:
>>
>> > 
>> >  Animals
>> >  Buildings
>> >  Cars
>> >  People
>> > 
>>
>> > So only the last element in the URL has to stay, and a hash has te be
>> > added...
>> > I wouldn't know how to achieve this. I've been googling it for three
>> > hours now, but i jus't can't get it to work.
>> > Any help would be greatly appreciated!
>>
>> > Thanks,
>> > Knal


[jQuery] Re: Manipulate href

2009-08-17 Thread Miloš Rašić

$('#my_list a').each(function() {

var hrefSplit = $(this).attr('href').split('/');
$(this).attr('href', '#'+hrefSplit(hrefSplit.length - 2));

});

2009/8/17 knal :
>
> Hi group,
>
> I'm looking for a correct way of manipulating  The code looks like this:
>
> 
>  Animals
>  Buildings
>  Cars
>  People
> 
>
> and with jQuery i want to manipulate it into this:
>
> 
>  Animals
>  Buildings
>  Cars
>  People
> 
>
> So only the last element in the URL has to stay, and a hash has te be
> added...
> I wouldn't know how to achieve this. I've been googling it for three
> hours now, but i jus't can't get it to work.
> Any help would be greatly appreciated!
>
> Thanks,
> Knal


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić

Then check the data you are sending to the server side script. There
are a few ways to do this.

In your JavaScript, you can make the data object before you call the
$.ajax() method. Then check the object in Firebug or do
alert(dataObject.FIRSTNAME) to see if it is properly formed.

You might also try to send the serialized form as data. If this works
then something is wrong with the object you are using. If you need the
PROCESS value for the script to work, include it as a hidden input in
your form.

You can print out the post data in your ASP script and then halt the
execution. The output should be available in your callback so you can
see if your server side script received all the data it should have
received.

2009/8/17 efet :
>
> I tried it as:
>
>        success: function(msg, textStatus){
>        alert( "Server Response: " + msg );
>        }
>
> Nothing changed.
>


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić

Did you try adding the textStatus parameter?

2009/8/17 efet :
>
> I tried alert, I alert box empty. But when I disable the jquery and
> submit the form as I used to, I get the error in the following format.
>
>  id='message' />sorry, you cannot use this email address.
>
> On Aug 17, 2:09 pm, Miloš Rašić  wrote:
>> I'm quite certain that output variable in your callback function
>> should contain the response of your server side script. In other
>> words, even if your server side script displays something like a
>> scripting language or database error, it should still be in the output
>> variable. If you think something is wrong with the code you are using
>> it to insert the response into the page, try using alert(output) in
>> the callback. It will give you the contents of output variable in a
>> browser dialog.
>>
>> On the other hand, your callback function might be invalid. It is
>> defined in the doucmentation as function(data, textStatus).
>> Try adding the textStatus parameter to your function even though you
>> don't use it and see if it changes anything.
>>
>> 2009/8/17 efet :
>>
>>
>>
>> > Great explanation, thank you so much. But I still cant grab output of
>> > page we sent the data. I still only get "Contact Form Submitted!"
>> > message, though I know my server side codes gave an error message.
>>
>> > On Aug 17, 1:39 pm, Miloš Rašić  wrote:
>> >> html() method set's the innerHTML of an element, which means that it
>> >> overwrites what was previously in it. What you should do is:
>> >> $("#SIGNUPFORM").html(output);
>> >> $('#SIGNUPFORM').append("Contact Form Submitted!");
>>
>> >> It would also be good for your programming for you to get a habit of
>> >> chaining methods whenever possible. As it is, your code will search
>> >> the DOM for #SIGNUPFORM twice unnecessarily. If you do it like:
>> >> $("#SIGNUPFORM").html(output).append("Contact Form Submitted!");
>> >> the element will be selected only once. You can chain the methods as
>> >> long as you will until you use a method that is supposed to return
>> >> something specific about the object (also called an inspector).
>>
>> >> I hope this helps.
>>
>> >> 2009/8/17 efet :
>>
>> >> > Ok now it partially worked! I get Contact Form Submitted! message once
>> >> > I click submit. But! there still is a one problem. When form
>> >> > submitted, if email address is used before, my server side script
>> >> > gives "sorry, you cannot use this email address" message. How can I
>> >> > grab other page's response text and print it to the page instead. I
>> >> > tried it as:
>>
>> >> > success: function(output) {
>> >> >                $("#SIGNUPFORM").html(output);
>> >> >                                $('#SIGNUPFORM').html("Contact
>> >> > Form Submitted!")
>> >> >                }
>>
>> >> > On Aug 17, 1:13 pm, Miloš Rašić  wrote:
>> >> >> Your page is refreshed? No wonder since you are using type="submit"
>> >> >> input. Change it to type="button" and add return false; at the end of
>> >> >> your onclick function just in case. return false; will prevent the
>> >> >> button from continuing with its default behaviour once your function
>> >> >> is complete.
>>
>> >> >> Submit inputs are used to submit a form (without AJAX) to a url
>> >> >> provided in the action attribute of your form. Since your form doesn't
>> >> >> have an action attribute, it assumes that the form should be posted to
>> >> >> the current url. Your function probably works, but once it is
>> >> >> completed the form submits normally without waiting for AJAX response.
>>
>> >> >> 2009/8/17 efet :
>>
>> >> >> > I missed few ""s there thank you. I am pasting the updated code here.
>> >> >> > I just installed firebug. I dont receive any errors, what happens is
>> >> >> > page is refreshed. Before moving to an easier method, I want to learn
>> >> >> > this method first. I am just a beginner yet. Do you think page is
>> >> >> > refreshed because I have method="post" in my form?
>>
>> >> >> > Updated code:
>> >> >> >    $(document).ready(function() {
>> >> >> >        $("[name='signup']").click(function() {
>> >> >> >                $.ajax({
>> >> >> >                    type: "POST",
>> >> >> >                                        data: { PROCESS: 
>> >> >> > "Add2Member", FIRSTNAME: "[name='FIRSTNAME']",
>> >> >> > LASTNAME: "[name='LASTNAME']", EMAILADDRESS: "[name='EMAILADDRESS']",
>> >> >> > PASSWORD: "[name='PASSWORD']", CITY: "[name='CITY']" },
>> >> >> >                                        url: "default.cs.asp",
>> >> >> >                success: function(output) {
>> >> >> >                $("#SIGNUPFORM").html(output);
>> >> >> >                                $('#SIGNUPFORM').html("Contact 
>> >> >> > Form Submitted!")
>> >> >> >                }
>> >> >> >                });
>> >> >> >        });


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić

I'm quite certain that output variable in your callback function
should contain the response of your server side script. In other
words, even if your server side script displays something like a
scripting language or database error, it should still be in the output
variable. If you think something is wrong with the code you are using
it to insert the response into the page, try using alert(output) in
the callback. It will give you the contents of output variable in a
browser dialog.

On the other hand, your callback function might be invalid. It is
defined in the doucmentation as function(data, textStatus).
Try adding the textStatus parameter to your function even though you
don't use it and see if it changes anything.

2009/8/17 efet :
>
> Great explanation, thank you so much. But I still cant grab output of
> page we sent the data. I still only get "Contact Form Submitted!"
> message, though I know my server side codes gave an error message.
>
>
> On Aug 17, 1:39 pm, Miloš Rašić  wrote:
>> html() method set's the innerHTML of an element, which means that it
>> overwrites what was previously in it. What you should do is:
>> $("#SIGNUPFORM").html(output);
>> $('#SIGNUPFORM').append("Contact Form Submitted!");
>>
>> It would also be good for your programming for you to get a habit of
>> chaining methods whenever possible. As it is, your code will search
>> the DOM for #SIGNUPFORM twice unnecessarily. If you do it like:
>> $("#SIGNUPFORM").html(output).append("Contact Form Submitted!");
>> the element will be selected only once. You can chain the methods as
>> long as you will until you use a method that is supposed to return
>> something specific about the object (also called an inspector).
>>
>> I hope this helps.
>>
>> 2009/8/17 efet :
>>
>>
>>
>> > Ok now it partially worked! I get Contact Form Submitted! message once
>> > I click submit. But! there still is a one problem. When form
>> > submitted, if email address is used before, my server side script
>> > gives "sorry, you cannot use this email address" message. How can I
>> > grab other page's response text and print it to the page instead. I
>> > tried it as:
>>
>> > success: function(output) {
>> >                $("#SIGNUPFORM").html(output);
>> >                                $('#SIGNUPFORM').html("Contact
>> > Form Submitted!")
>> >                }
>>
>> > On Aug 17, 1:13 pm, Miloš Rašić  wrote:
>> >> Your page is refreshed? No wonder since you are using type="submit"
>> >> input. Change it to type="button" and add return false; at the end of
>> >> your onclick function just in case. return false; will prevent the
>> >> button from continuing with its default behaviour once your function
>> >> is complete.
>>
>> >> Submit inputs are used to submit a form (without AJAX) to a url
>> >> provided in the action attribute of your form. Since your form doesn't
>> >> have an action attribute, it assumes that the form should be posted to
>> >> the current url. Your function probably works, but once it is
>> >> completed the form submits normally without waiting for AJAX response.
>>
>> >> 2009/8/17 efet :
>>
>> >> > I missed few ""s there thank you. I am pasting the updated code here.
>> >> > I just installed firebug. I dont receive any errors, what happens is
>> >> > page is refreshed. Before moving to an easier method, I want to learn
>> >> > this method first. I am just a beginner yet. Do you think page is
>> >> > refreshed because I have method="post" in my form?
>>
>> >> > Updated code:
>> >> >    $(document).ready(function() {
>> >> >        $("[name='signup']").click(function() {
>> >> >                $.ajax({
>> >> >                    type: "POST",
>> >> >                                        data: { PROCESS: "Add2Member", 
>> >> > FIRSTNAME: "[name='FIRSTNAME']",
>> >> > LASTNAME: "[name='LASTNAME']", EMAILADDRESS: "[name='EMAILADDRESS']",
>> >> > PASSWORD: "[name='PASSWORD']", CITY: "[name='CITY']" },
>> >> >                                        url: "default.cs.asp",
>> >> >                success: function(output) {
>> >> >                $("#SIGNUPFORM").html(output);
>> >> >                                $('#SIGNUPFORM').html("Contact Form 
>> >> > Submitted!")
>> >> >                }
>> >> >                });
>> >> >        });


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić

html() method set's the innerHTML of an element, which means that it
overwrites what was previously in it. What you should do is:
$("#SIGNUPFORM").html(output);
$('#SIGNUPFORM').append("Contact Form Submitted!");

It would also be good for your programming for you to get a habit of
chaining methods whenever possible. As it is, your code will search
the DOM for #SIGNUPFORM twice unnecessarily. If you do it like:
$("#SIGNUPFORM").html(output).append("Contact Form Submitted!");
the element will be selected only once. You can chain the methods as
long as you will until you use a method that is supposed to return
something specific about the object (also called an inspector).

I hope this helps.

2009/8/17 efet :
>
> Ok now it partially worked! I get Contact Form Submitted! message once
> I click submit. But! there still is a one problem. When form
> submitted, if email address is used before, my server side script
> gives "sorry, you cannot use this email address" message. How can I
> grab other page's response text and print it to the page instead. I
> tried it as:
>
> success: function(output) {
>                $("#SIGNUPFORM").html(output);
>                                $('#SIGNUPFORM').html("Contact
> Form Submitted!")
>                }
>
> On Aug 17, 1:13 pm, Miloš Rašić  wrote:
>> Your page is refreshed? No wonder since you are using type="submit"
>> input. Change it to type="button" and add return false; at the end of
>> your onclick function just in case. return false; will prevent the
>> button from continuing with its default behaviour once your function
>> is complete.
>>
>> Submit inputs are used to submit a form (without AJAX) to a url
>> provided in the action attribute of your form. Since your form doesn't
>> have an action attribute, it assumes that the form should be posted to
>> the current url. Your function probably works, but once it is
>> completed the form submits normally without waiting for AJAX response.
>>
>> 2009/8/17 efet :
>>
>>
>>
>> > I missed few ""s there thank you. I am pasting the updated code here.
>> > I just installed firebug. I dont receive any errors, what happens is
>> > page is refreshed. Before moving to an easier method, I want to learn
>> > this method first. I am just a beginner yet. Do you think page is
>> > refreshed because I have method="post" in my form?
>>
>> > Updated code:
>> >    $(document).ready(function() {
>> >        $("[name='signup']").click(function() {
>> >                $.ajax({
>> >                    type: "POST",
>> >                                        data: { PROCESS: "Add2Member", 
>> > FIRSTNAME: "[name='FIRSTNAME']",
>> > LASTNAME: "[name='LASTNAME']", EMAILADDRESS: "[name='EMAILADDRESS']",
>> > PASSWORD: "[name='PASSWORD']", CITY: "[name='CITY']" },
>> >                                        url: "default.cs.asp",
>> >                success: function(output) {
>> >                $("#SIGNUPFORM").html(output);
>> >                                $('#SIGNUPFORM').html("Contact Form 
>> > Submitted!")
>> >                }
>> >                });
>> >        });


[jQuery] Re: Saving the state of an ajax form

2009-08-17 Thread Miloš Rašić

I wouldn't count of all browsers to fill in the hidden inputs when the
user clicks the back button. In your place, I'd seriously consider
switching the form submission to AJAX. If you still want the user to
be able to go back with a back button, you could use deeplinking.

2009/8/17 north :
>
> I have to add that my colleague who coded the old version of this page
> used Sajax and "vanilla" JS, and his page works in all tested
> browsers. So I thought doing the same with jQuery should be as easy as
> it gets... :)
>
> On 17 Aug., 19:22, north  wrote:
>> Hi,
>>
>> I have a page with a simple form: 3 hidden fields and 3 selects.
>>
>> I load the data for the first select via Ajax on domready. I have
>> "change" event handlers for all 3 fields. If I select something in the
>> first select, the corresponding data gets loaded into the second
>> select via Ajax etc. So it's a "cascade" of selects.
>>
>> When an option in the 3rd select is being selected, I save the values
>> of all 3 selected options in the hidden fields, and create a button
>> for submitting the form.
>>
>> Until here everything works fine.
>>
>> When a users hits the submit button, he is being forwarded to a
>> results page. Now, when the user hits the back button, and the page
>> with the form gets loaded again, I check if the first hidden field has
>> a value.
>> If so, I try to fill all the form fields with the values the user had
>> entered (i.e. the selections he made), which means I make 3 Ajax calls
>> (to have all the data available), and mark the options the user had
>> selected as selected.
>>
>> That works fine in FF 3 and 3.5, Safari 4, as well as IE 7 right now.
>> IE 6 only display the data of the first select (as if the other two
>> Ajax calls aren't successful or something - no errors though), while
>> Opera 9 doesn't seem to remember the values of the 3 hidden fields
>> (same issue with IE 8, but I'm using IE Tester, which is not always
>> reliable).
>>
>> The html and jquery code (leaving out all the details) look like this:
>>
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Choose
>> 
>> 
>> Choose
>> 
>> 
>>
>> if (//hidden field has value) {
>>
>>         $.ajax({ //load data into the first field and mark the option which
>> got selected by the user as selected (using the value from the hidden
>> field)
>>                 }
>>         });
>>
>>         $.ajax({  //load data into the second field and mark the option which
>> got selected by the user as selected (using the value from the hidden
>> field)
>>         });
>>
>>         $.ajax({ //load data into the third field and mark the option which
>> got selected by the user as selected (using the value from the hidden
>> field)
>>         });
>>
>> }
>>
>> else { //hidden field has no value
>>
>>         $.ajax({ //load data into the first field
>>         });
>>
>> }
>>
>> $select2.change(function(){ //load data into select 2
>>
>> });
>>
>> $select2.change(function(){ //load data into select 3
>>
>> });
>>
>> $select3.change(function(){ // create hidden fields and submit button
>>
>> });
>>
>> Any help is highly appreciated.
>>
>> Thanks


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić

Your page is refreshed? No wonder since you are using type="submit"
input. Change it to type="button" and add return false; at the end of
your onclick function just in case. return false; will prevent the
button from continuing with its default behaviour once your function
is complete.

Submit inputs are used to submit a form (without AJAX) to a url
provided in the action attribute of your form. Since your form doesn't
have an action attribute, it assumes that the form should be posted to
the current url. Your function probably works, but once it is
completed the form submits normally without waiting for AJAX response.

2009/8/17 efet :
>
> I missed few ""s there thank you. I am pasting the updated code here.
> I just installed firebug. I dont receive any errors, what happens is
> page is refreshed. Before moving to an easier method, I want to learn
> this method first. I am just a beginner yet. Do you think page is
> refreshed because I have method="post" in my form?
>
> Updated code:
>    $(document).ready(function() {
>        $("[name='signup']").click(function() {
>                $.ajax({
>                    type: "POST",
>                                        data: { PROCESS: "Add2Member", 
> FIRSTNAME: "[name='FIRSTNAME']",
> LASTNAME: "[name='LASTNAME']", EMAILADDRESS: "[name='EMAILADDRESS']",
> PASSWORD: "[name='PASSWORD']", CITY: "[name='CITY']" },
>                                        url: "default.cs.asp",
>                success: function(output) {
>                $("#SIGNUPFORM").html(output);
>                                $('#SIGNUPFORM').html("Contact Form 
> Submitted!")
>                }
>                });
>        });


[jQuery] Re: Interaction in tabs

2009-08-17 Thread Miloš Rašić

You should ask that on jQuery UI group. I've never used the tabs. If
you can get a variable to be a pointer to the currently selected tab
with:
var selectedTab = somthing
you should then be able to do:
selectedTab.find('#columns > .column').length

The problem with the expression you are currently using is that it is
looking for the columns all over the document.

2009/8/17 lionel28 :
>
>
> You totally confuse me here. How do I know a tab is selected? When I click on
> it. All tabs have the same class
>
> ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header
> ui-corner-all">
>
> --
> View this message in context: 
> http://www.nabble.com/Interaction-in-tabs-tp25009915s27240p25010286.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>


[jQuery] Re: Form submit

2009-08-17 Thread Miloš Rašić
Doesn't your browser report some errors when you try to submit the
form? Try $("[name='signup']").click when you bind the function. I've
also never seen the object notation quite like what you are using for
your data parameter. Shouldn't it be something like
$("[name='LASTNAME']").val()? If you want to select your form fields,
you should really give them ids and select them with # selector. It's
much faster that way.

Also note that there is a much simpler way to submit your form:
$.post(url, $('#form').serialize(), callback);

2009/8/17 efet :
>
> Hi,
> Can someone tell me why the following form submit codes are not
> working. When I click submit, I want to see other page's output and
> form submitted text but instead nothing appears.
>
>
>    $(document).ready(function() {
>        $([name=signup]).click(function() {
>                $.ajax({
>                        type: "POST",
>                        data: { PROCESS: "Add2Member", FIRSTNAME:
> [name=FIRSTNAME], LASTNAME: [name=LASTNAME], EMAILADDRESS:
> [name=EMAILADDRESS], PASSWORD: [name=PASSWORD], CITY: [name=CITY] },
>                        url: "default.cs.asp",
>                success: function(output) {
>                $("#SIGNUPFORM").html(output);
>                                $('#SIGNUPFORM').html("Contact Form 
> Submitted!")
>                }
>                });
>        });
>    });
>
>                       
>                            
>                                
>                                    Adınız
>                                     name="FIRSTNAME" size="55" value="" />
>                                    <%=err_FIRSTNAME%>
>                                
>                                
>                                    Soyadınz
>                                     size="55" value="" />
>                                    <%=err_LASTNAME%> small>
>                                
>                                
>                                    E-posta Adresiniz
>                                     name="EMAILADDRESS" size="55" value="" />
>                                    <%=err_EMAILADDRESS%> small>
>                                
>                                
>                                    Şifreniz
>                                     size="55" value="" />
>                                    <%=err_PASSWORD%>
>                                
>                                
>                                    Yaşadığınız Yer
>                                     size="55" value="" />
>                                    <%=err_CITY%>
>                                
>                                
>                                     value="Kaydol" class="signup" />
>                                
>                            
>                        


[jQuery] Re: Interaction in tabs

2009-08-17 Thread Miloš Rašić

How do you know when a tab is selected? The most usual way is to give
it a class. If the class is called "selected", you should try
something like $('.tab.selected #columns > .column').length

2009/8/17 lionel28 :
>
>
> Hello,
>
> I have 6 tabs. Each one of them contain many elements with class 'column'
>
> I'd like to know, when a tab is selected, how many such elements in that
> selected tab.
>
> no matter how I tried, it gives me the right count on the first one selected
> and start incrementing them for all subsequent selected.
>
> $('#columns > .column').length;
>
> How can I get that value just for selected tab?
>
> Thank you.
> --
> View this message in context: 
> http://www.nabble.com/Interaction-in-tabs-tp25009915s27240p25009915.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>


[jQuery] $(this).offset().left vs parseInt($(this).css('left'))

2009-08-17 Thread Miloš Rašić

Anyone know an answer to this question? In case when both expressions
return the same value, which one is faster? $(this).offset().left or
parseInt($(this).css('left'))?


[jQuery] Re: How get data objects from a php file called via ajax

2009-01-15 Thread Miloš Rašić
Try fixing your html in the php code like this:

 echo '';
You forgot to close that class property in the input.

On Thu, Jan 15, 2009 at 12:12 PM, Mikael  wrote:

>
> I am new to javascript and jQuery programming so my problem might be
> very simple to explain but please bare with me.
>
> I want to make a selection in a list created by a php-file that is
> called from another php-file using jQuery and ajax but it fails.
> My example is very limited but shows the main problem.
>
> The first php-file has abutton defined like this:
>  
>
> I also have a div to show the result:
>  Show the result here
>
> The jQuery entry looks like this:
> jQuery(document).ready(function($) {
>$('.mini_browse').bind("click", function() {
>$.ajax({
>type: "get", url: "test-ajax.php", data: { action:
> 'test' },
>error: function() {$("#myresult").html("Ajax
> error");},
>success: function(html){ //so, if data is retrieved,
> store it in
> html
>$("#myresult").html(html);
>}
>}); //close jQuery.ajax
>return false;
>});
> });
>
> When I click the button I get a call to test-ajax.php as expected and
> the output is displayed in the myresult div but not as expected.
>
> The test-ajax.php executes this:
>  echo ' id="test_select_1" value="Select" />';
>
> The button is not displayed as a button but like an input text with
> the text "Select" in it and I can not get a click event from it.
> I can not see the output from test-ajax.php when I view the page
> source so I guess that I have to get it included in the document
> somehow but how?
>
> Can anybody point me in the right direction to solve this?
>
> Thanks!
>
>


[jQuery] Re: .animate() queue without pause between animations

2009-01-14 Thread Miloš Rašić
I don't think so. The number of pixels is not a fixed number between the
positions in the menu. There are 5 icons and 5 positions, so I use an array
of 5 objects that contain css properties(left, top, zIndex, width, height
and opacity) of each position. The problem with calling .animate() once is
that each icon has to move through an adjacent position before moving on to
the destination. If I call .animate() only once with the final destination,
it will move in a direct line which is not a desired effect.
On Wed, Jan 14, 2009 at 5:52 AM, Karl Swedberg wrote:

> Is it possible to have a variable for the number of pixels by which the
> menu animates (and doubling it when necessary), rather than calling animate
> twice?
> Also, .animate() is part of jQuery core, so you've posted to the correct
> group. ;-)
>
> --Karl
>
> 
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com
>
>
>
>
> On Jan 13, 2009, at 4:29 PM, Miloš Rašić wrote:
>
> Here's the function I use to rotate the menu:
> http://paste.pocoo.org/show/99509/
> The icons are located inside divs with ids 'pos_1' through 'pos_5', 'pos_1'
> being the leftmost icon, and 'pos_5' being the rightmost icon. The all have
> class 'pos'.
>
> The problematic case occurs when the user clicks on 'pos_1' or 'pos_5' and
> the menu has to be rotated by 2 steps. rotate() is then called twice, and so
> the call to .animate() is executed twice for each div. I can't use a single
> call to .animate() because then the divs would jump directly to their final
> destination instead of passing through adjacent positions.
>
> I've tried the following alternatives:
>
> 1) Using queue: false and using the second call with setTimeout so that it
> is executed just before the first animation completes.
>
> 2) Using queue: true as in original code but calling .stop() a fraction of
> a second before the first animation completes on its own so that it is
> interrupted and the second animation in the queue starts immediately.
>
> 3) Putting the second call to .animate() in the callback function of the
> first animate.
>
> All of these alternatives produced exactly the same results as the original
> code. The rotating menu makes a noticeable pause after the first animation
> before proceeding with the second.
>
> On Tue, Jan 13, 2009 at 8:20 PM, Nikola  wrote:
>
>>
>> It's hard to tell without having a look at the code.  You may want to
>> try http://paste.pocoo.org to post code like this.
>>
>> Are you chaining the animations? ie. $(this).animate({},speed).animate
>> ({},speed).animate({},speed);
>>
>> You could always try setting a delay on your second animation with
>> setTimeout.
>>
>> setTimeout ('$(this).animate({},speed)', 400);
>>
>> Hope that helps.
>> Nikola
>
>
>
>


[jQuery] Re: .animate() queue without pause between animations

2009-01-14 Thread Miloš Rašić
Thanks a lot to you and Karl for help. The animation works smoothly now. I
had to switch to animating without queue and using setTimeout for the second
rotation. It would be nice if jQuery would provide some functionality to the
queues where we could choose if we want a pause between animations and how
long it should be.

On Tue, Jan 13, 2009 at 11:05 PM, Nikola  wrote:

>
> What about doing something similar to what Karl Swedberg did in his
> animated scrolling example?
>
> http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12


[jQuery] Re: In this code, what would $(this) in the success part refer to?

2009-01-14 Thread Miloš Rašić
Since you're already discussing $(this), I'd like to ask something.
It is a good practice to assign selected nodes to variables if you are going
to need them more than once so as not to make jQuery search the document for
them again and again. What about $(this)? Do I need to assign it to a
variable or is it fast enough for repeated use?


[jQuery] Re: Jquery 1.2.3 does not return a type for radio controls?

2009-01-13 Thread Miloš Rašić
I have no idea if there is a bug like that, but I use this kind of
construction to determine if an element is something I need it to be:
if ($('#element_id:radio').attr('id')=='element_id')

You can use many other : selectors to check if an element is something like
an input of a type or visible or animated, etc. I really wish there were
some jQuery functions for this. I don't see a better cross-browser way to do
this. Just selecting a non-existing element will return an Object just like
an existing element. .attr('id') on a non-existing element will return
'undefined' on some browsers and 'null' on others.

On Tue, Jan 13, 2009 at 9:15 PM, Scott Sharkey
wrote:

>
> Hi All,
>
> I'm stuck with Jquery 1.2.3 in a trac-based application.  I'm trying to get
> the type of a form control, to determine what mechanism I should use to set
> it's value (ie, text controls use .val(), checkboxes get .attr("checked",
> "checked") etc.).  When I fetch my list of controls, and loop through them
> with each, printing the value of .attr('type') on each... the text,
> checkbox, and textarea types work fine, but radio controls come up
> undefined. Is this a jquery bug?  Does anyone know if/when it was fixed?
>  Maybe I can port that patch back to 1.2.3 to solve my problem.
>
> Any other suggestions appreciated.
>
> -Scott
>


[jQuery] Re: Code simplification?

2009-01-13 Thread Miloš Rašić
MorningZ is absolutely right, but if you notice that a certain class is used
only by a single element, you should make it an id, which is equally usable
by CSS and jQuery. For example, if those s are part of navigation menu
as they seem to be, I would have




On Tue, Jan 13, 2009 at 8:31 PM, MorningZ  wrote:

>
> If you have control on the HTML, it would be a LOT easier/cleaner/make-
> more-sense if you separate classes
>
> for instance
>
> 
> 
> 
> 
>
> to
>
> 
> 
> 
> 
>
> That would make your jQuery life much easier, plus it makes the items
> actually have "common" class characteristics
>
> Now when you want to manipulate them all:
>
> $("li.nav_sub").doSomejQueryAction
>
> and yet they all still have their unique styles/characteristics
>
>
>
>


[jQuery] Re: How to make this work for multiple elements with same class

2009-01-13 Thread Miloš Rašić
Instead of href="##", put href="javascript: return false". It will work, but
be warned that FF will generate a warning because return is not inside a
function.

On Tue, Jan 13, 2009 at 10:06 PM, Rick Faircloth
wrote:

>
> Thanks, Josh...
>
> You were almost perfect.  I just needed to add one more .next to the second
> line:
>
> $(this).parent().next().next().fadeIn(500);
>
> then it worked.
>
> Another question however, is how to keep the page from going back to the
> top
> every time the Update link is clicked.  I've got two ## as the href because
> of
> ColdFusion need to have two.  Is that the problem, or is there another
> solution?
>
> Update
>
> That's the current code.  Suggestions?
>
> Thanks,
>
>


[jQuery] Re: .animate() queue without pause between animations

2009-01-13 Thread Miloš Rašić
Here's the function I use to rotate the menu:
http://paste.pocoo.org/show/99509/
The icons are located inside divs with ids 'pos_1' through 'pos_5', 'pos_1'
being the leftmost icon, and 'pos_5' being the rightmost icon. The all have
class 'pos'.

The problematic case occurs when the user clicks on 'pos_1' or 'pos_5' and
the menu has to be rotated by 2 steps. rotate() is then called twice, and so
the call to .animate() is executed twice for each div. I can't use a single
call to .animate() because then the divs would jump directly to their final
destination instead of passing through adjacent positions.

I've tried the following alternatives:

1) Using queue: false and using the second call with setTimeout so that it
is executed just before the first animation completes.

2) Using queue: true as in original code but calling .stop() a fraction of a
second before the first animation completes on its own so that it is
interrupted and the second animation in the queue starts immediately.

3) Putting the second call to .animate() in the callback function of the
first animate.

All of these alternatives produced exactly the same results as the original
code. The rotating menu makes a noticeable pause after the first animation
before proceeding with the second.

On Tue, Jan 13, 2009 at 8:20 PM, Nikola  wrote:

>
> It's hard to tell without having a look at the code.  You may want to
> try http://paste.pocoo.org to post code like this.
>
> Are you chaining the animations? ie. $(this).animate({},speed).animate
> ({},speed).animate({},speed);
>
> You could always try setting a delay on your second animation with
> setTimeout.
>
> setTimeout ('$(this).animate({},speed)', 400);
>
> Hope that helps.
> Nikola


[jQuery] .animate() queue without pause between animations

2009-01-13 Thread Miloš Rašić

I'm using .animate() for a rotating navigation menu of 5 items, where
the currently selected item is in the center. When I click on an icon
next to the central everything works ok, but when I click on an icon
to the far left or far right, two calls to .animate() are needed per
icon for all icons to move correctly. The problem is that there is
about a second of pause between the two animations for the same icon
when I set queue: true. The effect is the same if I put the other call
to .animate() into callback function of the first. Is there any way to
get a seamless animation using multiple calls to .animate()? I tried
queue: false but, as expected, the second call to .animate() will
interrupt the first and the icons will not move correctly.