nikku/jquery-bootstrap-scripting

Ajaxifying links on new content

Closed this issue · 8 comments

Hi,

I tried everything, and I'm hitting a wall. I have a table that get updated by $.get, now the new content have some links that follow the rules of "Automatically ajaxifying links on a web page", they work fine before I update the table through ajax, but when the table get updated, they stop working, I tried to call

$(document).controls();

but I get an error when I click on the link that says:

Uncaught TypeError: Cannot call method 'prepend' of undefined

following the debugger in chrome, it's complaining about this line:

parentHandle.prepend(new FocusCatcher(this.__handle, true));

Could you help please.

Thanks!

Please tell me your browser as well as the dialog2 plugin and jQuery versions used and show me how you use the plugin in html/js code.

I'm sorry, it works now, strange, I think it's a matter of ordering my code, I think I miss placed $(document).controls();

Thanks!

I ran into this issue too during this specific use case. I haven't found a fix:

  1. AJAX dialog is opened by user
  2. HTML content that appears behind the dialog (on the original page) is dynamically updated, including a required call to $(document).controls()
  3. AJAX dialog is closed by user
  4. Clicking of any link that normally opens an AJAX dialog results in the above "Uncaught TypeError: Cannot call method 'prepend' of undefined" error.

This issue only occurs when the HTML content is updated while the AJAX dialog is open. If I keep the dialog closed, or, close it before the HTML content is updated, the error does not occur.

I have tied into two dialog2 callbacks, dialog2.content-update and dialog2.before-ajaxify, though I don't believe these are related to the issue.

I have a similar problem

  1. A link with class="open-dialog ajax" is dynamically updated, changing its href to a NEW value
  2. Click this link after it has been updated will open a dialog using the OLD (previous) href parameters for the ajax call.

I tried $(documents).controls() after updating the link, but its not working. ¿Is there a way to unbind and then rebind using $(documents).controls()?

Ok, I dont know how i didnt notice this but it took me quite some time to realize that the plugin removes the open-dialog class once $(documents).controls(); is called.

So you just have to add the class again and call $(documents).controls() if you want to change the ajax url on open-dialog.

Hope this helps and sorry if i caused any confusion

Nice if you were able to fix it.
I probably should rewrite controls() at some point to use $.on() to bind ajax-content, too.

Cheers
Nico

Closing this and opening a new issue

I have a similar problem too. This issue was solved?