1
My system works in the form of SPA (Single Page Application), I load all the functions that I will use in the system in a single file (which is light by the way), the problem is that every time I load a page, I need to redeem inputs with Jquery, my doubt is the following: I won’t be overloading the browser by calling several times the same element in Jquery?
Here’s an example of my code:
var editContact = function(){
$("#element").mask();
//Call Google Maps
}
File that will be loaded several times by jQuery.load();
<script>
new editContact();
</script>
<input id="#element">
I would be overloading the system every time I load the page, since I call the editContact() function every time?
The problem is that this part: "<input id="element"> <div id="result"></div>" is not in the document yet, as it will be loaded in the future when the user clicks on the link.
– Kol
My index would look something like this: <body><div class="page"></div></body> and whenever the user clicks on another page it loads this editcontact.php page and calls this function in jQuery
– Kol
If it is a another different page, then the script will be loaded the same way as it is to be executed when the page is ready. If it is a single page platform can trigger the
.mask()
when theclick
to call the other section happens. Or use the last example I posted, which will create the.mask()
(even for dynamically created elements) when something in the input changes or a key is primed$(document).on('change keyup'...
. That’s why I put that example there on purpose– Chun
Got it, thank you very much Chun
– Kol