Bug Tracker

Modify

Ticket #1884 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

javascript, loaded via ajax not binding inside a parent element.

Reported by: frankysanders Owned by:
Priority: major Milestone: 1.2.2
Component: ajax Version: 1.2.1
Keywords: Cc:
Blocking: Blocked by:

Description

Steps to reproduce.

1) load ajax via .ajax() method 2) put in dom via (id).html(ajax_result);

The following example works:

ajax_result =

<a href="#">hello</a>
<script> 
    alert('I will execute');
    $(document).ready(function(){
         $("a").click(function() {alert('hi');});
    })
</script>

Howerver, this example does not:

ajax_result =

<div>
<a href="#">hello</a>
<script> 
    alert('I will execute');
    $(document).ready(function(){
         $("a").click(function() {alert('hi, but you won\'t see me');});
    })
</script>
</div>

Notice that the only difference is that one binding happens inside of a parent element.

I've tested this behavior in IE 7 and FF 2.0.0.8

I'm not sure if this behavior be expected to work as it's generally recommended to leave javascript out of the body of a document however sometimes it's necessary.

Attachments

jquery_test.html Download (1.3 KB) - added by davidserduke 5 years ago.
test case

Change History

comment:1 Changed 5 years ago by davidserduke

  • Component changed from core to ajax

See #1519 and #1959 that are similar.

Changed 5 years ago by davidserduke

test case

comment:2 Changed 5 years ago by davidserduke

  • Status changed from new to closed
  • Resolution set to fixed

This appears to be fixed in SVN rev 4092 (it did fail in 1.2.1). There were several changes made to that section of the code but none were specficially made for this ticket so if something still doesn't work please reopen with additional information/test cases.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.