Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Java][AJAX]Ajax Live nie działa Tooltip oraz toggle
casperii
post
Post #1





Grupa: Zarejestrowani
Postów: 681
Pomógł: 28
Dołączył: 14.08.2014

Ostrzeżenie: (0%)
-----


Panowie, wczytuje wyniki poprzez ajax na stronę, lecz nie działa w wynikach dialog czy tooltip.
  1. function search() {
  2. var value = $('input#name').val();
  3. if(value !== ''){
  4. $.ajax({
  5. type: "POST",
  6. url: "/ajaxSearch.php",
  7. data: { query: value },
  8. cache: false,
  9. success: function(html){
  10. $("#table").html(html);
  11. }
  12. });
  13. }return false;
  14. }


poza pobraniem wyników poprzez ajax tooltip czy toggle działa bez problemów, konsola też nic nie wywala.

Problem rozwiązany w połowie, dla tooltip wystarczy zrobić:
  1. $(document).on('mouseover',function () {
  2. $("[data-toggle=tooltip]").tooltip();
  3. });


ale dla toggle() problem pozostaje dalej.

Ten post edytował casperii 10.05.2017, 00:25:50
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
casperii
post
Post #2





Grupa: Zarejestrowani
Postów: 681
Pomógł: 28
Dołączył: 14.08.2014

Ostrzeżenie: (0%)
-----


@bostaf po wczytaniu HTMLa poprzez ajaxa dane są takie same ID etc.

może problem polega w tym, że te dane są tak jakby z zewnątrz wczytywane ?

poniżej kod JS dla toggle:
  1. var uiDropdown = new function() {
  2. var self;
  3. self = this;
  4. this.hideDialog = function($el) {
  5. return $el.find(".dialog").hide().removeClass("is-visible");
  6. };
  7. this.showDialog = function($el) {
  8. return $el.find(".dialog").show().addClass("is-visible");
  9. };
  10. return this.initialize = function() {
  11. $("html").click(function() {
  12. $(".ui-dropdown .head").removeClass("active");
  13. return self.hideDialog($(".ui-dropdown"));
  14. });
  15. $(".ui-dropdown .body").click(function(e) {
  16. return e.stopPropagation();
  17. });
  18. return $(".ui-dropdown").each(function(index, el) {
  19. return $(el).click(function(e) {
  20. e.stopPropagation();
  21. $(el).find(".head").toggleClass("active");
  22. if ($(el).find(".head").hasClass("active")) {
  23. return self.showDialog($(el));
  24. } else {
  25. return self.hideDialog($(el));
  26. }
  27. });
  28. });
  29. };
  30. };


ale nijak nie mogę tego ugryźć.
Go to the top of the page
+Quote Post
bostaf
post
Post #3





Grupa: Zarejestrowani
Postów: 374
Pomógł: 79
Dołączył: 6.04.2010
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Cytat(casperii @ 10.05.2017, 22:24:28 ) *
może problem polega w tym, że te dane są tak jakby z zewnątrz wczytywane ?

Tak. Tutaj to jest wyjaśnione:
Cytat
Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time.


I gdzieś widziałem zalecenie, żeby zamiast starych eventhandlerów "click", "keydown", ... używać on(), tak jak to zrobiłeś z tooltipem. Chociażby dlatego, że radzą sobie z elementami dodawanymi dynamicznie.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.09.2025 - 16:55