Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectable not working in a modal #78

Closed
mlavin opened this issue Nov 10, 2013 · 5 comments
Closed

Selectable not working in a modal #78

mlavin opened this issue Nov 10, 2013 · 5 comments

Comments

@mlavin
Copy link
Owner

mlavin commented Nov 10, 2013

When the form in which a autocomplete is used, is presented within a bootstrap modal (as in http://stackoverflow.com/questions/11944887/jquery-ajax-django-present-form-in-a-bootstrap-modal-and-re-show-if-validati), the functionality is lost.
Any idea on how to solve this?

Thanks!


@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

Thanks Mark!


Original Comment By: Philippe Luickx

@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

Mark, you are a hero! Works like a charm!
Hope this issue thread will be useful to someone else too one day.


Original Comment By: Philippe Luickx

@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

bindSelectables is defined in jquery.dj.selectable.js so you would need to ensure that it is included on the page even if the form using it isn't included on page load.

For the context you should use the smallest container selector which includes all of the selectable fields/widgets. For your case bindSelectables("#Modal"); should work just fine since that's where the new form is being injected.


Original Comment By: Mark Lavin

@mlavin mlavin closed this as completed Nov 10, 2013
@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

Thanks for the pointer Mark! I tried playing around with the bindSelectables, but not getting far yet...
The call is indeed done through AJAX, which would be something like:

:::javascript
<script>
    $(".modal").click(function(ev) { // for each edit contact url
        ev.preventDefault(); // prevent navigation
        var url = $(this).data("form"); // get the contact form url
        $("#Modal").load(url, function() { // load the url into the modal
            $(this).modal('show'); // display the modal on url load
// This position would make sense...
            bindSelectables();
        });
        return false; // prevent the click propagation
    });

</script>

However, hitting 2 issues

  • ReferenceError: bindSelectables is not defined >> no idea on this...
  • What to pass as context? Would $("#Modal") work?

Big fat disclaimer: I am definitely no javascript wizkid...

Thanks for the help!


Original Comment By: Philippe Luickx

@mlavin
Copy link
Owner Author

mlavin commented Nov 10, 2013

I'm not sure I understand the issue. Is the modal being loaded via AJAX call? If so then you would need to ensure that bindSelectables is called once the form is loaded into the modal.


Original Comment By: Mark Lavin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant