|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with $ functionI use dwr for form functions. I have a problem with function $. It does not detect my dropdown menu as an element. I tried to print the value of the element within $ like this $(element) it says the value is "undefined". But actually the dropdown menu holds values. Because of this other functions which depends on it doesnt work. I tried to implement this without server then it works fine. Do you guys have any help for me?
Thanks Prasanna |
|
|
Re: Problem with $ functionAny other JS library included there?
On Mon, Jun 23, 2008 at 11:31 AM, sri prasanna <machosry@...> wrote: I use dwr for form functions. I have a problem with function $. It does not detect my dropdown menu as an element. I tried to print the value of the element within $ like this $(element) it says the value is "undefined". But actually the dropdown menu holds values. Because of this other functions which depends on it doesnt work. I tried to implement this without server then it works fine. Do you guys have any help for me? |
|
|
Re: Problem with $ function$ is short for document.getElementById. Are you sure you are providing
a valid id? You should have: $("elemendId") Not: $(element) Secondly this could be a conflict with another js framework. Are you using any other JavaScript framework? sri prasanna wrote: > I use dwr for form functions. I have a problem with function $. It > does not detect my dropdown menu as an element. I tried to print the > value of the element within $ like this $(element) it says the value > is "undefined". But actually the dropdown menu holds values. Because > of this other functions which depends on it doesnt work. I tried to > implement this without server then it works fine. Do you guys have any > help for me? > > Thanks > Prasanna --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Problem with $ functionNo i dont ve any other library imported.. And i use elementID only. But still couldnt figure out the problem.
On Sun, Jun 22, 2008 at 9:35 PM, David Marginian <david@...> wrote: $ is short for document.getElementById. Are you sure you are providing a valid id? -- With Love, Sri Prasanna. K Blog: http://cancerb0y.wordpress.com GTalk: machosry GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry OpenMRS wiki:http://openmrs.org/wiki/User:Machosry |
|
|
Re: Problem with $ functionCan you attach your complete html and javascript please?
sri prasanna wrote: > No i dont ve any other library imported.. And i use elementID only. > But still couldnt figure out the problem. > > On Sun, Jun 22, 2008 at 9:35 PM, David Marginian > <david@... <mailto:david@...>> wrote: > > $ is short for document.getElementById. Are you sure you are > providing a valid id? > You should have: > $("elemendId") > Not: > $(element) > > Secondly this could be a conflict with another js framework. Are > you using any other JavaScript framework? > > > sri prasanna wrote: > > I use dwr for form functions. I have a problem with function > $. It does not detect my dropdown menu as an element. I tried > to print the value of the element within $ like this > $(element) it says the value is "undefined". But actually the > dropdown menu holds values. Because of this other functions > which depends on it doesnt work. I tried to implement this > without server then it works fine. Do you guys have any help > for me? > > Thanks > Prasanna > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > For additional commands, e-mail: users-help@... > <mailto:users-help@...> > > > > > -- > With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Problem with $ functionHere they are...
On Sun, Jun 22, 2008 at 9:43 PM, David Marginian <david@...> wrote: Can you attach your complete html and javascript please? -- With Love, Sri Prasanna. K Blog: http://cancerb0y.wordpress.com GTalk: machosry GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry OpenMRS wiki:http://openmrs.org/wiki/User:Machosry --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Problem with $ functionSri,
I am assuming your problem is here: function getCountryList(){ var country = AddressHierarchy.getCountryList(); alert($(country)); DWRUtil.removeAllOptions("country"); DWRUtil.addOptions("country", country); DWRUtil.setValue(parentId,null); } Is that correct? You need to go through some of the documentation on DWR's site and perhaps the some of the examples in the war file (or maybe one of the many tutorials on the web). First: DWR makes asynchronous calls by default. That means that var country is always going to be undefined because code execution will not wait for the remote methods return value. You need to specify a callback function: AddressHierarchy.getCountryList(myCallBackFunction); function myCallBackFunction(dataFromServer) { alert(dwr.util.toDescriptiveString(dataFromServer, 3)); DWRUtil.removeAllOptions("country"); DWRUtil.addOptions("country", country); DWRUtil.setValue(parentId,null); } Second: I don't think alert($(country)); could be correct anyway. You were expecting country to be the data you get back from the remote call right? I don't see what you are trying to do here. If you want to see the remote data use dwr.util.toDescriptiveString like I have above. sri prasanna wrote: > Here they are... > > On Sun, Jun 22, 2008 at 9:43 PM, David Marginian > <david@... <mailto:david@...>> wrote: > > Can you attach your complete html and javascript please? > > sri prasanna wrote: > > No i dont ve any other library imported.. And i use elementID > only. But still couldnt figure out the problem. > > On Sun, Jun 22, 2008 at 9:35 PM, David Marginian > <david@... <mailto:david@...> > <mailto:david@... > <mailto:david@...>>> wrote: > > $ is short for document.getElementById. Are you sure you are > providing a valid id? > You should have: > $("elemendId") > Not: > $(element) > > Secondly this could be a conflict with another js > framework. Are > you using any other JavaScript framework? > > > sri prasanna wrote: > > I use dwr for form functions. I have a problem with > function > $. It does not detect my dropdown menu as an element. I > tried > to print the value of the element within $ like this > $(element) it says the value is "undefined". But > actually the > dropdown menu holds values. Because of this other functions > which depends on it doesnt work. I tried to implement this > without server then it works fine. Do you guys have any > help > for me? > > Thanks > Prasanna > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > <mailto:users-unsubscribe@... > <mailto:users-unsubscribe@...>> > > For additional commands, e-mail: > users-help@... <mailto:users-help@...> > <mailto:users-help@... > <mailto:users-help@...>> > > > > > > -- > With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): > http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > For additional commands, e-mail: users-help@... > <mailto:users-help@...> > > > > > -- > With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry > ------------------------------------------------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Problem with $ functionThanks David. But the problem is i receive the values in the form of an array and I can see them using firebug in the response console. Thats why I am confused. I used alert($country) just to see what the $ gives out. Consider I have a text element some x if alert($(x)) is called then it has to popup with the text value. But here it doesnt. Thats y im struggling here.
This is the response I see in firebug var s0=[];var s1="india";s0[0]=s1; var s2="ina";s0[1]=s2; var s3="mina";s0[2]=s3; var s4="misana";s0[3]=s4; var s5="miana";s0[4]=s5; var s6="nigeria";s0[5]=s6; var s7="United Arabs";s0[6]=s7; var s8="rwanda";s0[7]=s8; var s9="argentina";s0[8]=s9; DWREngine._handleResponse('9638_1214277400265', s0);On Sun, Jun 22, 2008 at 10:05 PM, David Marginian <david@...> wrote: Sri, -- With Love, Sri Prasanna. K Blog: http://cancerb0y.wordpress.com GTalk: machosry GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry OpenMRS wiki:http://openmrs.org/wiki/User:Machosry |
|
|
Re: Problem with $ functionI am sorry that you are confused but I am seriously questioning if you
have spent any time reading the available documentation. If you would listen to my advice your code will work. Once it does I recommend you spending some time on the DWR site going through the examples and tutorials so you actually understand why what you are doing is wrong. function getCountryList(){ var country = AddressHierarchy.getCountryList(); alert($(country)); DWRUtil.removeAllOptions("country"); DWRUtil.addOptions("country", country); DWRUtil.setValue(parentId,null); } You are defining a variable called country and that variable is set to AddressHierarchy.getCountryList(); var country = AddressHierarchy.getCountryList(); In this case country will ALWAYS be undefined because you have not specified a callback function. Since the DWR call is made asynchrously we are not waiting around for a return value to assign to country. The reason you are seeing that response in the Firebug console is because the DWR call is STILL made you will just have no idea of when it returns without specifying a callback function. Your alert makes no sense. The $ sign can be used in place of document.getElementById so you are essentially saying document.getElementById(undefined). Now if you did this: alert($("country")) with quotes around the country the alert would attempt to display the dom node with an id of country in your jsp (would probably show you [object] in IE). sri prasanna wrote: > Thanks David. But the problem is i receive the values in the form of > an array and I can see them using firebug in the response console. > Thats why I am confused. I used alert($country) just to see what the $ > gives out. Consider I have a text element some x if alert($(x)) is > called then it has to popup with the text value. But here it doesnt. > Thats y im struggling here. > > This is the response I see in firebug > var s0=[];var s1="india";s0[0]=s1; > var s2="ina";s0[1]=s2; > var s3="mina";s0[2]=s3; > var s4="misana";s0[3]=s4; > var s5="miana";s0[4]=s5; > var s6="nigeria";s0[5]=s6; > var s7="United Arabs";s0[6]=s7; > var s8="rwanda";s0[7]=s8; > var s9="argentina";s0[8]=s9; > DWREngine._handleResponse('9638_1214277400265', s0); > > > > > > On Sun, Jun 22, 2008 at 10:05 PM, David Marginian > <david@... <mailto:david@...>> wrote: > > Sri, > I am assuming your problem is here: > > function getCountryList(){ > var country = AddressHierarchy.getCountryList(); > alert($(country)); > DWRUtil.removeAllOptions("country"); > DWRUtil.addOptions("country", country); > DWRUtil.setValue(parentId,null); > } > > Is that correct? You need to go through some of the documentation > on DWR's site and perhaps the some of the examples in the war > file (or maybe one of the many tutorials on the web). > First: > DWR makes asynchronous calls by default. That means that var > country is always going to be undefined because code execution > will not wait for the remote methods return value. > > You need to specify a callback function: > > AddressHierarchy.getCountryList(myCallBackFunction); > > function myCallBackFunction(dataFromServer) { > alert(dwr.util.toDescriptiveString(dataFromServer, 3)); > DWRUtil.removeAllOptions("country"); > DWRUtil.addOptions("country", country); > DWRUtil.setValue(parentId,null); > } > > Second: > I don't think alert($(country)); could be correct anyway. You > were expecting country to be the data you get back from the remote > call right? I don't see what you are trying to do here. If you > want to see the remote data use dwr.util.toDescriptiveString like > I have above. > > > sri prasanna wrote: > > Here they are... > > > On Sun, Jun 22, 2008 at 9:43 PM, David Marginian > <david@... <mailto:david@...> > <mailto:david@... > <mailto:david@...>>> wrote: > > Can you attach your complete html and javascript please? > > sri prasanna wrote: > > No i dont ve any other library imported.. And i use > elementID > only. But still couldnt figure out the problem. > > On Sun, Jun 22, 2008 at 9:35 PM, David Marginian > <david@... > <mailto:david@...> > <mailto:david@... > <mailto:david@...>> > <mailto:david@... > <mailto:david@...> > > <mailto:david@... > <mailto:david@...>>>> wrote: > > $ is short for document.getElementById. Are you > sure you are > providing a valid id? > You should have: > $("elemendId") > Not: > $(element) > > Secondly this could be a conflict with another js > framework. Are > you using any other JavaScript framework? > > > sri prasanna wrote: > > I use dwr for form functions. I have a problem with > function > $. It does not detect my dropdown menu as an > element. I > tried > to print the value of the element within $ like this > $(element) it says the value is "undefined". But > actually the > dropdown menu holds values. Because of this > other functions > which depends on it doesnt work. I tried to > implement this > without server then it works fine. Do you guys > have any > help > for me? > > Thanks > Prasanna > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > users-unsubscribe@... > <mailto:users-unsubscribe@...> > <mailto:users-unsubscribe@... > <mailto:users-unsubscribe@...>> > <mailto:users-unsubscribe@... > <mailto:users-unsubscribe@...> > <mailto:users-unsubscribe@... > <mailto:users-unsubscribe@...>>> > > For additional commands, e-mail: > users-help@... > <mailto:users-help@...> > <mailto:users-help@... > <mailto:users-help@...>> > <mailto:users-help@... > <mailto:users-help@...> > <mailto:users-help@... > <mailto:users-help@...>>> > > > > > > -- With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): > http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > <mailto:users-unsubscribe@... > <mailto:users-unsubscribe@...>> > For additional commands, e-mail: > users-help@... <mailto:users-help@...> > <mailto:users-help@... > <mailto:users-help@...>> > > > > > -- > With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): > http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry > ------------------------------------------------------------------------ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > For additional commands, e-mail: users-help@... > <mailto:users-help@...> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > <mailto:users-unsubscribe@...> > For additional commands, e-mail: users-help@... > <mailto:users-help@...> > > > > > -- > With Love, > Sri Prasanna. K > Blog: http://cancerb0y.wordpress.com > GTalk: machosry > GSoC wiki(for only GSoCians): http://socwiki.natulte.net/student:machosry > OpenMRS wiki:http://openmrs.org/wiki/User:Machosry --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |