0

From a shortcut visual composer modal gallery i would like to get an input value from a modal and put it into another one in the same modal. gallery_short_cut

galllery_short_cut_inputs

i could not get access to inputs value , i test if the page contains the modal an alert will appear . the problem that inputs are shown in the navigator inspector if modal is opened . is there any way to get the input values.

jQuery(document).ready(function() {
    if (jQuery(".wpb_element_wrapper")[0]) {
        alert("hello world"); 
    }              
});
Yannic Hamann
  • 4,655
  • 32
  • 50
presta dev
  • 19
  • 2
  • 11
  • Can you provide the html of the element you are targeting. Visual composer is going to generate dynamic elements, you should add the code from the resultant website post saving the visual composer. – anurag Aug 09 '18 at 10:26

1 Answers1

0

Probable Cause: You have defined jQuery function on an element that yet doesn't exist on the page. So the function exists but hasn't bind to any element.

Probable Solution: You could bind the function on the element that could come in future too, e.g.

$("body").on("change", ". wpb_element_wrapper", function(){
    $(".other_input_class").val($(this).val());
});

Further read: You can refer to jquery's on method and also this answer.

anurag
  • 2,176
  • 2
  • 22
  • 41
  • when the modal is loaded , i would that the input with class .ids get a static text for example , id doesn't get it – presta dev Aug 09 '18 at 09:55
  • jQuery(document).ready(function( ){ jQuery("body").on("change", ".wpb_element_wrapper", function(){ jQuery(".ids").val("testt"); }); }); – presta dev Aug 09 '18 at 09:57
  • either , i test if the specified element is focused : – presta dev Aug 09 '18 at 10:02
  • jQuery(document).ready(function( ){ jQuery(".ids").focus(function(){ alert("test"); }); }); – presta dev Aug 09 '18 at 10:02
  • is `wpb_element_wrapper` the input element? also to answer your `when the modal is loaded` you could do, $('#my-modal').on('shown', function(){ $(".ids").val("test"); }); where my-modal is the id of the modal you opened. – anurag Aug 09 '18 at 10:06
  • i have revirified with changin css modal color by inspector , its id is vc_ui-panel-edit-element . – presta dev Aug 09 '18 at 10:15
  • jQuery(document).ready(function( ){ jQuery('#vc_ui-panel-edit-element').on('shown', function(){ alert("test") }); }); doesn't work – presta dev Aug 09 '18 at 10:16
  • `#vc_ui-panel-edit-element` this is probably the id of the edit element inside the visual composer and probably something you might not be able to control. You could add your `id="my-modal"` attribute to the modal, and the use `$('#my-modal').on('shown', function(){ $(".ids").val("test"); });` Should work. – anurag Aug 09 '18 at 10:24
  • yes i show the file id="vc_ui-panel-edit-element" when i modified the id , of course modal could not be opened – presta dev Aug 09 '18 at 10:40
  • solved by adding only where ids and imgs are input on the modal : jQuery(window).click(function() { jQuery(".ids").val(jQuery(".imgs").val()); }); – presta dev Aug 09 '18 at 11:54