Can you remove the _onclick from that element and add that function call to
the end of your listener defined in document ready?

-Jim


On Wed, Nov 4, 2020 at 8:29 PM mostwanted <godirao...@gmail.com> wrote:

> _onclick="updatelivesearch(jQuery('#res%s').html())" % c.service_name
>
> This is a function that displays suggested names through ajax
> auto-completion everytime a user types something on the search-textfield.
> When they type, a suggestion-div appears below the search-field with
> suggested names as links ofcourse and when the users identifies the name
> they were looking for & clicks on it this function populates the
> search-textfield with the clicked name & causes the suggestion-div with
> names to disappear.
>
> function updatelivesearch(value){
> jQuery("#livesearch").val(value);
> jQuery("#livesearchresults").hide();
> }
>
> Thanks alot for your input Jim i'll keep working on it, one way or the
> other i'll figure it out.
> Gratitude.
>
>
> On Wednesday, November 4, 2020 at 7:34:44 PM UTC+2 Jim S wrote:
>
>> What is the
>>
>> _onclick="updatelivesearch(jQuery('#res%s').html())" % c.service_name
>>
>> on your anchor tag inside your span?
>>
>> Can you try removing that?
>>
>> Since you have a listener for the click of that element already, I'm not
>> sure how it behaves if you have the onclick attribute set as well.  Maybe
>> there are some stronger javascript people that can jump in.
>>
>> -Jim
>>
>>
>> On Wednesday, November 4, 2020 at 11:23:45 AM UTC-6, mostwanted wrote:
>>>
>>>
>>> *" Are you trying to show the span when the link is clicked 'while' the
>>> page is loaded?  ":  *Yes sir
>>>
>>> *" I'm guessing you are clicking the link after the page is loaded ": *Yes
>>> sir
>>>
>>> *"Also, where in your javascript did you add the console.log()?":  *I
>>> added it inside the click function just before initialization of the id
>>> variable
>>>
>>> *<script>*$(document).ready(function(){
>>>             $('.service').click(function(e) {
>>> *console.log( "Hello world!" );*
>>>         const id = $(this).data('id');
>>>         $('#' + id).fadeIn();
>>>         e.preventDefault();
>>>
>>>             });
>>>             });
>>> *</script>*
>>> On Wednesday, November 4, 2020 at 4:09:12 PM UTC+2 Jim S wrote:
>>>
>>>> Ok, trying to better understand your intent.
>>>>
>>>> You said:
>>>>
>>>> I have a hidden span that i want displayed when a link is clisked
>>>> while waiting for the page to load but this is not working! I dont
>>>> know where I am going wrong but thought I had it right, please assist me.
>>>>
>>>> Are you trying to show the span when the link is clicked 'while' the
>>>> page is loaded?  I'm guessing you are clicking the link after the page is
>>>> loaded.  Can you confirm?
>>>>
>>>> Also, where in your javascript did you add the console.log()?
>>>>
>>>> -Jim
>>>>
>>>>
>>>> On Wednesday, November 4, 2020 at 12:34:02 AM UTC-6, mostwanted wrote:
>>>>>
>>>>> I threw in  console.log("Hello world!");  but its not printing
>>>>> anything on the console! The link events are not being handled!
>>>>>
>>>>>
>>>>> On Tuesday, November 3, 2020 at 11:35:19 PM UTC+2 Jim S wrote:
>>>>>
>>>>>> Can you put some console.log() statements in your javascript inside
>>>>>> your function to see what is/isn't working?
>>>>>>
>>>>>> -Jim
>>>>>>
>>>>>>
>>>>>> On Tuesday, November 3, 2020 at 12:10:06 PM UTC-6, mostwanted wrote:
>>>>>>>
>>>>>>> Hey Jim, I have but it shows no errors!
>>>>>>>
>>>>>>> On Tuesday, November 3, 2020 at 6:02:50 PM UTC+2 Jim S wrote:
>>>>>>>
>>>>>>>> Have you checked your browser console to see if you have any
>>>>>>>> javascript errors?
>>>>>>>>
>>>>>>>> -Jim
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tuesday, November 3, 2020 at 3:36:22 AM UTC-6, mostwanted wrote:
>>>>>>>>>
>>>>>>>>> I have a hidden span that i want displayed when a link is clisked
>>>>>>>>> while waiting for the page to load but this is not working! I dont 
>>>>>>>>> know
>>>>>>>>> where I am going wrong but thought I had it right, please assist me.
>>>>>>>>>
>>>>>>>>> *CSS:*
>>>>>>>>> .link_loader
>>>>>>>>> {
>>>>>>>>>     display: none;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> *CONTROLLER*
>>>>>>>>> *#The yellow line is the hidden span that has the loader I want to
>>>>>>>>> display*
>>>>>>>>> def ajaxlivesearch():
>>>>>>>>>     keywords = request.vars.keywords
>>>>>>>>>     print "Keywords: " + str(keywords)
>>>>>>>>>
>>>>>>>>>     if keywords:
>>>>>>>>>         query = reduce(lambda
>>>>>>>>> a,b:a&b,[db.services.service_name.contains(k) for k in 
>>>>>>>>> keywords.split()])
>>>>>>>>>     services = db(query).select()
>>>>>>>>>     items = []
>>>>>>>>>
>>>>>>>>> if services:
>>>>>>>>>         for c in services:
>>>>>>>>>             items.append(DIV*(SPAN("loading ...", SPAN(_class="fa
>>>>>>>>> fa-spinner fa-spin"), _class="link_loader",
>>>>>>>>> data={'id':"res%s"%c.service_name})*, A(c.service_name,
>>>>>>>>> _class="service", _style="font-weight: bold;", _href=URL('companies', 
>>>>>>>>> args=
>>>>>>>>> c.id), _id="res%s"%c.service_name,
>>>>>>>>> _onclick="updatelivesearch(jQuery('#res%s').html())" % 
>>>>>>>>> c.service_name)))
>>>>>>>>>
>>>>>>>>> *VIEW*
>>>>>>>>> *#This jQuery script attempts to display the hidden span*
>>>>>>>>>
>>>>>>>>> *<script>*$(document).ready(function(){
>>>>>>>>>             $('.service').click(function(e) {
>>>>>>>>>         const id = $(this).data('id');
>>>>>>>>>         $('#' + id).fadeIn();
>>>>>>>>>         e.preventDefault();
>>>>>>>>>
>>>>>>>>>             });
>>>>>>>>>             });
>>>>>>>>>
>>>>>>>>> *</script>*
>>>>>>>>>
>>>>>>>>> Regards;
>>>>>>>>>
>>>>>>>>> Mostwanted
>>>>>>>>>
>>>>>>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/O9iXEbdOkFE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/4863b201-a4eb-4f4c-b9bd-edb6ca808acdn%40googlegroups.com
> <https://groups.google.com/d/msgid/web2py/4863b201-a4eb-4f4c-b9bd-edb6ca808acdn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAERBpoBhDAC%2BkKGsxNsVYo1yq2tM4sY92e294_j%2BSESVVAcfBg%40mail.gmail.com.

Reply via email to