[jQuery] Define functions before DOM loads
How can we define functions even before the DOM loads fully. I tried like (function() { msg = function() { alert(Hello User); } }); $(function() { msg(); }); This is just an example. But it gives me Object Expected error. Please let me know how to do it.
[jQuery] Re: Define functions before DOM loads
Got it. I need to define as (function() { msg = function() { alert(Hello User); } })(); Thats it. On Feb 19, 11:08 am, JQueryProgrammer jain.ashis...@gmail.com wrote: How can we define functions even before the DOM loads fully. I tried like (function() { msg = function() { alert(Hello User); } }); $(function() { msg(); }); This is just an example. But it gives me Object Expected error. Please let me know how to do it.
[jQuery] Optimized Function to transfer Array to Listbox
I have two array of items containing the values and text to be inserted in a Listbox. I had written the function as: array2Listbox = function(objListBox, arrValue, arrText) { var oNewOption; return jQuery.each(arrValue, function(i) { oNewOption = new Option(arrText[i], arrValue[i]); objListBox[objListBox.length] = oNewOption; }); }; However I know jQuery would be much slower than direct for loop in this case where the array size is approx 6000 elements. Can anyone tell me a faster way to loop through the array and insert the elements in Listbox.
[jQuery] JSON with .Net
I am trying to use JSON with jquery and .Net. I am using json2.js for JavaScript and Newtonsoft.JSON for .Net serialization. Here goes my code: JavaScript --- $.ajax({ url: http://localhost/JSONSample/default.aspx;, method: GET, datatype: json, contentType: application/json; charset=utf-8, data: {name: 'User'}, success: function(result) { var oResult = JSON.parse(result); alert(oResult.Guid); }, error: function() { alert(Some error occured); } }); Server side code protected void Page_Load(object sender, EventArgs e) { if(Request.Params[name] != null Request.Params[name].ToString () != ) { GetName(); } } public void GetName() { System.Web.Script.Serialization ser = new System.Web.Script.Serialization(); System.Text.StringBuilder oBuilder = new System.Text.StringBuilder(); oBuilder.Append({); oBuilder.AppendFormat('{0}' : '{1}', Guid, Guid.NewGuid()); oBuilder.Append(}); string json = ser.Serialize(oBuilder.ToString()); Response.Write(json); Response.Flush(); Response.Close(); } I am able to get the result in success function. But the oResult.Guid is undefined. When I am trying to alert oResult, it gives me: { 'Guid' : '16ba666a-cd2a-41b6-b0b1-5f072d44d488' } Can anyone help me why is the oResult.Guid undefined..?
[jQuery] jQuery.support query
The utilities jQuery.browser and jQuery.version has been deprecated in jQuery 1.3 version and the documentation says to use jQuery.support for the same. But I do not find any options for browser and version in jQuery.support. Although they have been included in 1.3 release too, but are deprecated. How can we then check the browser name and version..?
[jQuery] Re: Select all controls of the form
I want to convert some existing code from traditional javascript for loop to $.each. Here is my code: var oEl = document.getElementById(my_form_id).elements; for(var i=0; i oEl.length; i++) { //do something } In jquery I have written a $.fn.extend function and the code as: $.fn.extend({ test: function() { //I want to filter only input controls from hte form var $this = $(this).filter(:input); $.each($this, function() { //do something }); } }) $(#my_form_id).test(); But it is not working. On Jan 13, 12:05 pm, Karl Rudd karl.r...@gmail.com wrote: Errr img elements aren't form controls. input type=image elements are but :input selects those. I'm not sure what you mean. Karl Rudd On Tue, Jan 13, 2009 at 5:43 PM, JQueryProgrammer jain.ashis...@gmail.com wrote: The above code selects all the controls except img tag. On Jan 13, 11:26 am, Karl Rudd karl.r...@gmail.com wrote: The '*' selector will select _all_ the nodes (including the br/s). Try using the ':input' selector: $(#form1 :input) http://docs.jquery.com/Selectors Karl Rudd On Tue, Jan 13, 2009 at 5:16 PM, JQueryProgrammer jain.ashis...@gmail.com wrote: I am trying to validate all the controls that exist in the form. My form code looks like: form id=form1 input type=text id=txt1 name=txt1 / br/ textarea name=txtArea id=txtArea cols=100 rows=4 / br/ select id=sel1 name=sel1 style=width: 250px; option value=Select/option option value=1One/option option value=2Two/option option value=3Three/option /select br/ input type=radio id=rdo1 name=rdo1 value=Option1nbsp;Option 1nbsp; br/ input type=radio id=rdo2 name=rdo1 value=Option2nbsp;Option 2nbsp; br/ button id=btn1Submit/button button id=btn2Reset/button /form I want to select only the controls of the form viz: textbox, textarea, select, radio button (Total 7). I am trying to extract them as $(#form1 *).each(function() { alert($(#+this).attr(id)); }) it gives me total 16 alerts. I want just 7. Any help..?
[jQuery] Select all controls of the form
I am trying to validate all the controls that exist in the form. My form code looks like: form id=form1 input type=text id=txt1 name=txt1 / br/ textarea name=txtArea id=txtArea cols=100 rows=4 / br/ select id=sel1 name=sel1 style=width: 250px; option value=Select/option option value=1One/option option value=2Two/option option value=3Three/option /select br/ input type=radio id=rdo1 name=rdo1 value=Option1nbsp;Option 1nbsp; br/ input type=radio id=rdo2 name=rdo1 value=Option2nbsp;Option 2nbsp; br/ button id=btn1Submit/button button id=btn2Reset/button /form I want to select only the controls of the form viz: textbox, textarea, select, radio button (Total 7). I am trying to extract them as $(#form1 *).each(function() { alert($(#+this).attr(id)); }) it gives me total 16 alerts. I want just 7. Any help..?
[jQuery] Re: Select all controls of the form
The above code selects all the controls except img tag. On Jan 13, 11:26 am, Karl Rudd karl.r...@gmail.com wrote: The '*' selector will select _all_ the nodes (including the br/s). Try using the ':input' selector: $(#form1 :input) http://docs.jquery.com/Selectors Karl Rudd On Tue, Jan 13, 2009 at 5:16 PM, JQueryProgrammer jain.ashis...@gmail.com wrote: I am trying to validate all the controls that exist in the form. My form code looks like: form id=form1 input type=text id=txt1 name=txt1 / br/ textarea name=txtArea id=txtArea cols=100 rows=4 / br/ select id=sel1 name=sel1 style=width: 250px; option value=Select/option option value=1One/option option value=2Two/option option value=3Three/option /select br/ input type=radio id=rdo1 name=rdo1 value=Option1nbsp;Option 1nbsp; br/ input type=radio id=rdo2 name=rdo1 value=Option2nbsp;Option 2nbsp; br/ button id=btn1Submit/button button id=btn2Reset/button /form I want to select only the controls of the form viz: textbox, textarea, select, radio button (Total 7). I am trying to extract them as $(#form1 *).each(function() { alert($(#+this).attr(id)); }) it gives me total 16 alerts. I want just 7. Any help..?
[jQuery] Window.Open code
I am trying to write a code for window.open in jQuery. here is my code: OpenNewWindow = function(strURL, winName, options) { this._settings = $.extend({ toolbar: no, location: no, directories: no, status: no, menubar: no, scrollbars: no, resizable: yes, width: 100, height: 100 }, options || {}); I am now stuck at the below line. Whether I shouyld write as: window.open(strURL, winName, this._settings); or have I to include all the options for this. I also know that jQwery UI's dialog s another alternative for it, but then I need to change my current aspx page for it to get the values back from the dialog. Can ayone guide me as to what can be my OpenNewWindow code look like. Any more ideas for window.open would e highly appreciated.
[jQuery] Re: HttpHandler not returning JSON data
I did try and am able to use the json.net class for it. The HttpHandler is returning json data now. Thanks. Now I was trying to get 10 items from the json file. My url in $.getJSON looks like: $.getJSON(myjsonfile.json?count=10, {}, function(data) { $.each(data, function(i, item) { alert(item.title); alert(i); }); }); But the above code returns all 20 items in my file. What mistakes am I making? On Dec 28, 3:57 pm, MorningZ morni...@gmail.com wrote: Want to make life MUCH easier than all those IE-specific hacks? Check out Json.NET http://james.newtonking.com/pages/json-net.aspx On Dec 28, 1:15 am, JQueryProgrammer jain.ashis...@gmail.com wrote: I got the solution to this. Actually this code was working in Firefox and not in IE. When I tried to run in IE, it was giving error 12030 (Server unexpectedly terminated connection) from IE's XMLHttpRequest object. The solution: In my HttpHandler I included the code: System.IO.Stream st = context.Request.InputStream; byte[] buf = new byte[100]; while (true) { int iRead = st.Read(buf, 0, 100); if (iRead == 0) break;} st.Close(); Actually ASp.Net does not read the complete incoming input stream automatically. In order for IE's XMLHttpRequest object to properly read return stream the input stream must be completely read by the server (even if you are not interested in it). On Dec 28, 10:29 am, JQueryProgrammer jain.ashis...@gmail.com wrote: Hi All, I was working with a basic example where I wanted to get JSON data from the HttpHandler. My javascript code looks like: $.ajax({ url: 'Handler1.ashx', type: 'POST', data: { name: 'MyName' }, contextType: 'application/json; charset=utf-8', dataType: 'json', success: function(data) { alert(Data Saved + data.name); } }); My Handler1.ashx code looks like: context.Response.ContentType = application/json; string results = { 'name': '+ context.Request.Params[name] +' }; context.Response.Write(results); But I am not getting the results right. Infact I am not getting any result in data.name. Please let me know what is the mistake and what is the correct way to get JSON data.
[jQuery] $.getJSON not returning specified count
Hi, I was trying to get 10 items from the json file. My url in $.getJSON looks like: $.getJSON(myjsonfile.json?count=10, {}, function(data) { $.each(data, function(i, item) { alert(item.title); alert(i); }); }); But the above code returns all 20 items from my file. What mistakes am I making?
[jQuery] Re: $.getJSON not returning specified count
It contains all items from my json file. The file looks like: [ {title:Title1}, {title:Title2}, {title:Title3}, ... ... {title:Title20} ] On Dec 29, 4:55 pm, MorningZ morni...@gmail.com wrote: What's the returned JSON look like? On Dec 29, 6:50 am, JQueryProgrammer jain.ashis...@gmail.com wrote: Hi, I was trying to get 10 items from the json file. My url in $.getJSON looks like: $.getJSON(myjsonfile.json?count=10, {}, function(data) { $.each(data, function(i, item) { alert(item.title); alert(i); }); }); But the above code returns all 20 items from my file. What mistakes am I making?
[jQuery] Re: jQuery.getJSON Current Url Prefixed
Is your http://remoteServer page a json file or is it returning a json data? buaziz wrote: hi am using jQuery.getJSON to request a cross-domain page using the following code jQuery.getJSON(crossDomainUrl, function(result) { processResult(result); }); but i never reach the cross domain url as the current url is always prefixed to it, like so Current Page Url : http://localhost/page.aspx Cross Domain Url : http://remoteServer getJSON final request url is : http://localhost/page.aspxhttp://remoteServer so i always get a 404 error can you please tell me why is this happening thanks -- View this message in context: http://www.nabble.com/jQuery.getJSON-Current-Url-Prefixed-tp21201707s27240p21201707.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: jQuery.getJSON Current Url Prefixed
Can u paste the remote server url over here. I will try from my local m/c. I tried the sample given on http://docs.jquery.com /Ajax/jQuery.getJSON#urldatacallback and it works perfectly fine. On Dec 29, 6:34 pm, buaziz bua...@gmail.com wrote: the remoteServer is returning JSON data. -- View this message in context:http://www.nabble.com/jQuery.getJSON-Current-Url-Prefixed-tp21201707s... Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: jQuery.getJSON Current Url Prefixed
Try this code: $.getJSON(http://www.panoramio.com/map/get_panoramas.php? order=popularityset=publicfrom=0to=20minx=-180miny=-90maxx=180maxy=90size=mediumcallback=?, {}, function(data) { $(data).each(function(i, item) { alert($(this)[0].photos[i].photo_id); }) } ); See if it helps :) On Dec 29, 8:30 pm, buaziz bua...@gmail.com wrote: its basically the panoramio url given here http://www.panoramio.com/api/ sample query : http://www.panoramio.com/map/get_panoramas.php?order=popularityset=p... -- View this message in context:http://www.nabble.com/jQuery.getJSON-Current-Url-Prefixed-tp21201707s... Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] jQuery ajax Samples
Hi All, I was wondering whether I could find any good basic examples for $.ajax where I could find how to use the options of the $.ajax. I wanted to see how we can use the dataType: 'xml' / 'json' / 'html' etc options to capture respective data and use them. docs.jquery.com provides very basic syntax without the server side code.
[jQuery] HttpHandler not returning JSON data
Hi All, I was working with a basic example where I wanted to get JSON data from the HttpHandler. My javascript code looks like: $.ajax({ url: 'Handler1.ashx', type: 'POST', data: { name: 'MyName' }, contextType: 'application/json; charset=utf-8', dataType: 'json', success: function(data) { alert(Data Saved + data.name); } }); My Handler1.ashx code looks like: context.Response.ContentType = application/json; string results = { 'name': '+ context.Request.Params[name] +' }; context.Response.Write(results); But I am not getting the results right. Infact I am not getting any result in data.name. Please let me know what is the mistake and what is the correct way to get JSON data.
[jQuery] Re: AJAX with IE and method POST
Thanks a ton George. You saved my day. I have been trying to getting this issue and was searching for a solution. Your post helped. On Nov 15, 1:29 am, George gev @comcast.net wrote: No i did not...I did pass exactly this '{}' (empty JSON data). As i said the problem was that i were not reading the InputStream till the end cause i knew that data would be empty. And it messes up IE's XMLHttpRequest object so it can not read properly output from the server. George. On Nov 14, 2:22 pm, Mike Nichols nichols.mik...@gmail.com wrote: did you forget to pass data (data:{}) in the ajax call? I have had that trip me up when doing posts via ajax. On Nov 14, 10:35 am, George gev...@comcast.net wrote: Hi guys/girls, I just wanted to post here my problems (and solution) I had been struggling with last 2 days. I was doing JQuery AJAX POST and it was not working in IE wile working in FireFox. Sometimes you will get12030error (Server unexpectedly terminated connection) from IE's XMLHttpRequest object. I discovered that in order for IE's XMLHttpRequest object to properly read return stream the input stream must be completely read by the server (even if you are not interested in it). Some frameworks do it automatically and some do not. For example ASP.NET does not do it automatically. I was trying to do POST to .ashx handler and was getting errors. So adding this code to my handler fixed the problem. System.IO.Stream st = context.Request.InputStream; byte []buf = new byte[100]; while (true) { int iRead = st.Read(buf, 0, 100); if( iRead == 0 ) break; } st.Close(); So I am just posing it for Google to spider it and people to be able to find it. Cause when I googled I found a lot of people having problem with12030error but no solution. Good luck, George- Hide quoted text - - Show quoted text -
[jQuery] Re: HttpHandler not returning JSON data
I got the solution to this. Actually this code was working in Firefox and not in IE. When I tried to run in IE, it was giving error 12030 (Server unexpectedly terminated connection) from IE's XMLHttpRequest object. The solution: In my HttpHandler I included the code: System.IO.Stream st = context.Request.InputStream; byte[] buf = new byte[100]; while (true) { int iRead = st.Read(buf, 0, 100); if (iRead == 0) break; } st.Close(); Actually ASp.Net does not read the complete incoming input stream automatically. In order for IE's XMLHttpRequest object to properly read return stream the input stream must be completely read by the server (even if you are not interested in it). On Dec 28, 10:29 am, JQueryProgrammer jain.ashis...@gmail.com wrote: Hi All, I was working with a basic example where I wanted to get JSON data from the HttpHandler. My javascript code looks like: $.ajax({ url: 'Handler1.ashx', type: 'POST', data: { name: 'MyName' }, contextType: 'application/json; charset=utf-8', dataType: 'json', success: function(data) { alert(Data Saved + data.name); } }); My Handler1.ashx code looks like: context.Response.ContentType = application/json; string results = { 'name': '+ context.Request.Params[name] +' }; context.Response.Write(results); But I am not getting the results right. Infact I am not getting any result in data.name. Please let me know what is the mistake and what is the correct way to get JSON data.
[jQuery] Re: Error getting value from server
Sorry for the spam. Actually my issue is that I am trying to keep my html file neat and tidy by putting all my javascript code in a separate js file. But my javascript code refers to some server side variable values which exists in an asp file. I have included that asp file in my main asp file along with the js file. But the js file dosn't seems to get server variable values. Here is a broad view of my code. mainpage.asp -- !--#include virtual = /mywebsite/child1.asp -- -- script type=text/javascript src=child1.js/script child1.asp -- CONST myvar = 100 child1.js -- alert(%= myvar%); But alert is giving error. Please advice change in the code if any. I can put the alert code in mainpage.asp too, but that will make my asp page full of javascript functions. I want to keep mainpage.asp clean. Thanks for the response. On Dec 10, 12:25 pm, brian [EMAIL PROTECTED] wrote: Please keep your threads tidy. Don't spam the list with the same question. The file that contains the line: var myvalue = %= myservervalue%; ... is a .js file, right? It's been a long time, but I'm guessing the ASP interpreter isn't set by default to parse .js files. Put the line in the head of the HTML file you're creating (ie. your ASP script): script type=text/javascript var myvalue = %= myservervalue%; /script And it's really not a good idea to create your own attributes for HTML elements. Not unless you reference your own DTD and, even then, you're looking for trouble. On Wed, Dec 10, 2008 at 12:34 AM, JQueryProgrammer [EMAIL PROTECTED] wrote: I am migrating my existing ASP application javascript code to jquery. However places where i want to get the value from server, I am getting an error like: var myvalue = %= myservervalue%; when i check in myvalue, it is populated with %= myservervalue% as string. If I try to remove then it gives an error in comparison. Any help would be appreciated.
[jQuery] Re: pleeease heeelp me nowwwwww
Try this: $(function() { // your code goes here. }); Also while including the jquery file, write it as: script type=text/javascript src=jquery.js/script Check whether this helps. On Dec 10, 2:17 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: hi i have written jquery for a site; after a while for sth that i don't know it don't work anymore and direbug give an error like this: $(div#peik) is null $(div#peik).hide(); and when i try to write $(document).ready() in firebug, it return : TypeError: $(document) is null whyyy is that? pleeeas answer as soon as posible thanks
[jQuery] Re: Top 5 Movies of the Box Office Watch Online
Stop spamming the group with such posts. This is irrelevant here. On Dec 11, 7:27 am, 24 Hrs Movies [EMAIL PROTECTED] wrote: Top 5 Movies of the Box Office http://newmegamovies.blogspot.com/ 1. Four Christmases Reese Witherspoon, Vince Vaughn, Mary Steenburgen 2. Twilight Kristen Stewart, Robert Pattinson, Billy Burke 3. Bolt John Travolta, Miley Cyrus, Susie Essman 4. Australia Nicole Kidman, Hugh Jackman 5. Quantum of Solace Daniel Craig, Olga Kurylenko, Mathieu Amalric Find Here http://newmegamovies.blogspot.com/2008/09/english-movies.html and Just click The tag...
[jQuery] Select option value not working
$(input[name='myselect'] option:selected).val(); is not working. It gives undefined. Can anyone please help.
[jQuery] Image.css(display) not working
image id=myimage myimgid=myimageid src=baloon.jpg / I want to check the style display for this image. I am doing as: $(image[myimgid='myimageid']).css(display); but its coming undefined. I cannot check it with id as my id is getting runtime generated. Please help.
[jQuery] Re: Select option value not working
Great. Thanks. lso is it possible to select an element based on the value it has. I have an button like input type=button value=GO / I want to attach an event to this button. How can I..? On Dec 9, 3:16 pm, Karl Rudd [EMAIL PROTECTED] wrote: Heh yeah that too. :) Sorry I missed that detail. Karl Rudd On Tue, Dec 9, 2008 at 9:08 PM, Rik Lomas [EMAIL PROTECTED] wrote: It could be to do with the select isn't an input tag, it's a select tag, try $(select[name='myselect'] option:selected).val(); instead Rik 2008/12/9 Karl Rudd [EMAIL PROTECTED]: The SELECT's value is what you want: $(input[name='myselect']).val() The only time you need to check is individual OPTIONs are selected is if you have a multi-select list box. Karl Rudd On Tue, Dec 9, 2008 at 8:09 PM, JQueryProgrammer [EMAIL PROTECTED] wrote: $(input[name='myselect'] option:selected).val(); is not working. It gives undefined. Can anyone please help. -- Rik Lomas http://rikrikrik.com
[jQuery] Re: Select option value not working
Ok. I got the answer. its like $(input[value='GO']) BUt now my problem is that while rendering the button is rendered as: input type=button value=GO onclick=myFunc(); / no I want to attach my event and cancel the default event, ie. I do not want to call the myFunc. But instead my own function that I have attached as: $(input[value='GO']).click(function(event) { event.preventDefault(); alert(Default Event Cancelled); }); But still its not canceling the default event. On Dec 9, 3:32 pm, JQueryProgrammer [EMAIL PROTECTED] wrote: Great. Thanks. lso is it possible to select an element based on the value it has. I have an button like input type=button value=GO / I want to attach an event to this button. How can I..? On Dec 9, 3:16 pm, Karl Rudd [EMAIL PROTECTED] wrote: Heh yeah that too. :) Sorry I missed that detail. Karl Rudd On Tue, Dec 9, 2008 at 9:08 PM, Rik Lomas [EMAIL PROTECTED] wrote: It could be to do with the select isn't an input tag, it's a select tag, try $(select[name='myselect'] option:selected).val(); instead Rik 2008/12/9 Karl Rudd [EMAIL PROTECTED]: The SELECT's value is what you want: $(input[name='myselect']).val() The only time you need to check is individual OPTIONs are selected is if you have a multi-select list box. Karl Rudd On Tue, Dec 9, 2008 at 8:09 PM, JQueryProgrammer [EMAIL PROTECTED] wrote: $(input[name='myselect'] option:selected).val(); is not working. It gives undefined. Can anyone please help. -- Rik Lomas http://rikrikrik.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups jQuery (English) group. To post to this group, send email to jquery-en@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-en?hl=en -~--~~~~--~~--~--~---
[jQuery] Re: Image.css(display) not working
Well I think you did not understand my quest correctly. As I said I cannot use the id for selector as my id is getting runtime generated. So i am using a custom attribute myimgid to select the element. I tried to use event.preventDefault too. but still its firing the original attached event. Any help would be appreciated. On Dec 9, 6:24 pm, donb [EMAIL PROTECTED] wrote: I don't think you're really understanding the selector syntax. The 'id' is unique (or is supposed to be) and starts with a '#' in a selector, and the css syntax uses a name and value pair to set the attribute. So: $(#myimage).css('display, inline); // or block or try this alternative: $(#myimage).show(); or possibly: $(#myimage).toggle() The last one displays when hidden and hides if already visible. I assume that 'myimg' is not something you really intended to use for the selector. On Dec 9, 7:16 am, JQueryProgrammer [EMAIL PROTECTED] wrote: image id=myimage myimgid=myimageid src=baloon.jpg / I want to check the style display for this image. I am doing as: $(image[myimgid='myimageid']).css(display); but its coming undefined. I cannot check it with id as my id is getting runtime generated. Please help.
[jQuery] Error getting value from server
I am migrating my existing ASP application javascript code to jquery. However places where i want to get the value from server, I am getting an error like: var myvalue = %= myservervalue%; when i check in myvalue, it is populated with %= myservervalue% as string. If I try to remove then it gives an error in comparison. Any help would be appreciated.
[jQuery] %= myvarvalue % not working. Urgent. Please help
I am net able to access my ASP server side constant value in jquery file. I am trying as: var myvar = %= myvarvalue %; but when i put an alert on myvar, it shows %= myvarvalue % and not the value of myvarvalue. Can anyone pls help. Its really urgent. Thanks in advance
[jQuery] Re: %= myvarvalue % not working. Urgent. Please help
Ok. I found the problem. The issue is that I am writing my code in separate .js file where I am trying to access server side variables which is giving error. Can anyone please let me know how can I include or import an asp page in my .js file to access variables and constant values in my included js file. On Dec 10, 11:50 am, JQueryProgrammer [EMAIL PROTECTED] wrote: I am net able to access my ASP server side constant value in jquery file. I am trying as: var myvar = %= myvarvalue %; but when i put an alert on myvar, it shows %= myvarvalue % and not the value of myvarvalue. Can anyone pls help. Its really urgent. Thanks in advance
[jQuery] Type of Control
How can I check what is the type of control. eg. In javascript document.getElementById(mycontrolid).type will return select-one, textbox, checkbox, radio etc. How can I find it in jQuery. I tried as $(#mycontrolid).constructor but it returns as Object in all cases.
[jQuery] Re: Type of Control
This is also one good way to get the type of the control. But is there any generic function that I can extend with jQuery in which I pass the control id and it returns me the type of the control whether it be div, span, select, textarea etc etc. On Dec 8, 4:00 pm, Richard D. Worth [EMAIL PROTECTED] wrote: Another option would be to use the .is() method in combination with jQuery form (pseudo-)selectors like select textarea :radio :checkbox :hidden See http://docs.jquery.com/Selectors the Forms: section for a list of the form pseudo-selectors. - Richard On Mon, Dec 8, 2008 at 5:34 AM, JQueryProgrammer [EMAIL PROTECTED]wrote: Thanks for the help. On Dec 8, 3:28 pm, Kayhadrin [EMAIL PROTECTED] wrote: If you try $(#mycontrolid).attr('type'), you should find the type of INPUT tag you have. On Dec 8, 9:05 pm, JQueryProgrammer [EMAIL PROTECTED] wrote: How can I check what is the type of control. eg. In javascript document.getElementById(mycontrolid).type will return select-one, textbox, checkbox, radio etc. How can I find it in jQuery. I tried as $(#mycontrolid).constructor but it returns as Object in all cases.
[jQuery] Re: Type of Control
Thanks for the help. On Dec 8, 3:28 pm, Kayhadrin [EMAIL PROTECTED] wrote: If you try $(#mycontrolid).attr('type'), you should find the type of INPUT tag you have. On Dec 8, 9:05 pm, JQueryProgrammer [EMAIL PROTECTED] wrote: How can I check what is the type of control. eg. In javascript document.getElementById(mycontrolid).type will return select-one, textbox, checkbox, radio etc. How can I find it in jQuery. I tried as $(#mycontrolid).constructor but it returns as Object in all cases.
[jQuery] Generic Handler returning JSON
Hi All, I am trying to get data back from the server by passing JSON values from jQuery. Find below my code: $(#btn).click(function() { $.ajax({ url: http://; + location.host + /AJAXSample/ GenericHandler.ashx, data: {name: 'Ted'}, type: GET, dataType: json, success: function(data) { var myarray = eval('(' + data.responseText + ')'); alert('Hello ' + myarray.Result); }, error: function(xhr) { alert('Error: ' + xhr.status + ' ' + xhr.statusText + ' ' + xhr.responseText); } }); return false; }); My server side code is: string myData = context.Request.Params[name]; context.Response.ContentType = text/plain; string myVal = { 'Result' : ' + myData + ' }; context.Response.Write(myVal); I am just trying to return JSON data from server. It is returning data but in alert box of success method it shows 'undefined'. Can anyone let me know where am i making a mistake. This is just sample I will use this logic to return complex data from server in further apps.
[jQuery] Re: jQuery select all vs conventional javascript
Ok got it and understood that the conventional javascript would be faster than jQuery in this case. But what I have seen is that just by pressing SHIFT+END, all the options in the listbox get selected. Is there some way we can fire that event to select all options. On Nov 20, 1:10 pm, Michael Geary [EMAIL PROTECTED] wrote: It's no surprise that the jQuery code is slower: you can always outperform jQuery with a custom-tuned loop. After all, jQuery has to do everything that your custom loop does, plus much more. For one thing, jQuery has to first build an array of all the items and then traverse that array. Your custom code doesn't have to build an array at all. You may be able to pick up a tiny bit more speed in your loop. First, make sure to var your i variable. If you don't var it, i is actually a property of the window object, and if this code is inside a function, that will make it slower to access the variable. Also, don't look up myListBox.length every time through the loop; you can either look it up once at the beginning or not at all. I would try these three variations on your loop and see if any of them comes up faster: for( var i = 0, n = myListBox.length; i n; ) myListBox[i++].selected = true; for( var i = myListBox.length; i 0; ) myListBox[--i].selected = true; for( var i = -1, option; option = myListBox[++i]; ) option.selected = true; I'll be curious to know the result. My guess is that one of those may be a bit faster, but still too slow to be acceptable. If that's the case, there may be nothing to be done for it except to do the selecting in batches of, say, 1000 elements with a short timeout between each batch. That way the browser will remain responsive while you run the loop. -Mike From: JQueryProgrammer I have been using jQuery for quite some time now. For one of my projects, I needed to select all the options in the listbox which were 10,000+. I tried to do a comparison between using jQuery and conventional javascript and here are my findings: 1. With jQuery: Code: $(#myListBox *).attr(selected,selected); Time taken: 7+ milliseconds 2. With JavaScript: Code: for( i=0; i myListBox.length; i++) { myListBox [i].selected = true; } Time taken: 21000+ milliseconds Can anyone provide with some better code or justify why is jQuery taking so much time.
[jQuery] jQuery select all vs conventional javascript
Hi All, I have been using jQuery for quite some time now. For one of my projects, I needed to select all the options in the listbox which were 10,000+. I tried to do a comparison between using jQuery and conventional javascript and here are my findings: 1. With jQuery: Code: $(#myListBox *).attr(selected,selected); Time taken: 7+ milliseconds 2. With JavaScript: Code: for( i=0; i myListBox.length; i++) { myListBox [i].selected = true; } Time taken: 21000+ milliseconds Can anyone provide with some better code or justify why is jQuery taking so much time. Also is it possible for me to raise a SHIFT+END command anyhow..?
[jQuery] Select all options on button click
Hi All, I am trying to write a JQuery function which would select all my options in the select control with the click of a button. I am able to do it with the following function: $(#btnAll).click(function() { $(#myselect *).attr(selected,selected); }); But the problem is my select list box has more than 5000 values and selecting each option with this method takes much time and scrolls the whole select box. Can anyone please help me in optimizing this function so that I can instantly select without the user getting displayed about the scrolling.
[jQuery] Re: Select all options on button click
Thanks for the reply. But this does not resolved my issue. I think client side code is always faster than server side code. Also I do not want to do a post back. I have also tried it with server side code but its even slower than the above code. Any other code would be appreciated. On Nov 7, 5:28 pm, Liam Potter [EMAIL PROTECTED] wrote: why not have an all option in your select box and do the rest server side? JQueryProgrammer wrote: Hi All, I am trying to write a JQuery function which would select all my options in the select control with the click of a button. I am able to do it with the following function: $(#btnAll).click(function() { $(#myselect *).attr(selected,selected); }); But the problem is my select list box has more than 5000 values and selecting each option with this method takes much time and scrolls the whole select box. Can anyone please help me in optimizing this function so that I can instantly select without the user getting displayed about the scrolling.
[jQuery] Simple Queires for Function calling
1. I have some simple queries with regards to function calling. In plain javascript if I want to call a javascript function from my HTMl tag i do it like: input type=text id=myid onclick=javascript:sayHello(this.id); value=World / Now my javascript function would be defined as function sayHello(id) { alert(Hello + id.value); } Now I want to use JQuery to do such kind of programming wherein some value (not necessary something from the attribute) is passed t o the function and processing is done. Can anyone please guide me as to how can it be acomplished.
[jQuery] contains() not working
I have an image tag as img id=myimg src=images/expand.jpg / I am trying as if($(#myimg).attr(src).contains(expand)) // do something else //do something else but it gives an error Object doesn't support this property of method. Please help.
[jQuery] Re: contains() not working
Thanks a ton. Although I had another way to do it like: if($(imgID).attr(src).indexOf(expand) = 0) but using the way you mentioned is more accurate and specific to JQuery. Thanks once again. On Sep 26, 2:27 pm, Richard D. Worth [EMAIL PROTECTED] wrote: contains is a pseudo-selector, but not a method. So you can use it like this: html before: pthe quick brown/p pfox jumped over/p pthe lazy dog/p script: $(p:contains('the')).remove(); html after: pfox jumped over/p That doesn't really help in the scenario you've posed because contains searches the text of the element (seehttp://docs.jquery.com/Selectors/contains#text). What you want is the attributeContains attribute selector. See: http://docs.jquery.com/Selectors Under Attribute Filters there is [attribute*=value] Matches elements that have the specified attribute and it contains a certain value.http://docs.jquery.com/Selectors/attributeContains#attributevalue So in your example that would be if ( $(#myimg[src*='expand']).length ) // do something else // do something else - Richard Richard D. Worthhttp://rdworth.org/ On Thu, Sep 25, 2008 at 11:21 PM, JQueryProgrammer [EMAIL PROTECTED]wrote: I have an image tag as img id=myimg src=images/expand.jpg / I am trying as if($(#myimg).attr(src).contains(expand)) // do something else //do something else but it gives an error Object doesn't support this property of method. Please help.
[jQuery] Re: Simple Queires for Function calling
Understand. But my issue is a bit different which i think i could not make it clear. I have a js file associated with every aspx page. Now my code is like input type=text id=myid onclick=javascript:sayHello(%= myValueFromServer%); / I tried to use the code (which is in my .js file) as: script type=text/javascript $(function() { //document.ready $(#myid).click(function() { alert( Hello + %= myValueFromServer% ); } }); But in .js file it does not resolve the %% value. Any help would be appreciated. On Sep 26, 2:13 pm, Richard D. Worth [EMAIL PROTECTED] wrote: The same with jQuery looks like this: input type=text id=myid value=World / script type=text/javascript $(function() { //document.ready $(#myid).click(function() { alert( Hello + $(this).val() ); } }); /script You don't have to pass anything to the function since the 'this' context variable is equal to the element to which the event was bound. If you want to pass some other value to the function, there are a couple of ways to do that, but which one to pick would really depend on the what/why. In other words, it's hard to say without a more real scenario. - Richard Richard D. Worthhttp://rdworth.org/ On Thu, Sep 25, 2008 at 11:22 PM, JQueryProgrammer [EMAIL PROTECTED]wrote: 1. I have some simple queries with regards to function calling. In plain javascript if I want to call a javascript function from my HTMl tag i do it like: input type=text id=myid onclick=javascript:sayHello(this.id); value=World / Now my javascript function would be defined as function sayHello(id) { alert(Hello + id.value); } Now I want to use JQuery to do such kind of programming wherein some value (not necessary something from the attribute) is passed t o the function and processing is done. Can anyone please guide me as to how can it be acomplished.
[jQuery] Problem with toggle
I am facing an issue with the toogle API. I have a tr with dynamic Id's as Id1, Id2 etc. Within that tr I have many td's in which one td has an image which needs to be toggled to plus image and minus image. That is when I click on the image, it should toggle between plus and minus images. Also when the image is clicked another tr should be displayed and hidden accordingly. That means a tr within a tr and the outer tr has an image. I was trying to write the code as: $([EMAIL PROTECTED]'myImgId']).toggle( function() { var $trId = #myTrId + $([EMAIL PROTECTED]'imgId']).index(this); $($trId).css(display,); $(this).attr(src,minus.jpg); }, function() { var $trId = #myTrId + $([EMAIL PROTECTED]'imgId']).index(this); $($trId).css(display,none); $(this).attr(src,plus.jpg); } ); But i am not getting the desired functionality of toggling. Please help
[jQuery] Reset values of Textboxes and Dropdowns
I have some textboxes and dropdowns on my page. now I already have a function which resets my fields. I can do it by $(#myFieldId)[0].value = ; OR $(#myFieldId)[0].selectedIndex = 0; Can I do it by some easy way..?
[jQuery] tr not applying CSS
I have a table that displays n rows based on the records from the database. For a particular row that gets displayed n times, I have assigned a name to the row. The row already has some CSS applied to it. But I want that whenever I take the mouse over the row, the new CC should get applied and the on mouse out the old CSS should reapply. I tried the code as: $(tr[name='myRowName').hover( function() { $(this).addClass(newClass); }, function() { $(this).removeClass(newClass); } ); But it does not work. Can anyone let me know.