How to add a JQuery library in Magento 1.9












0















I was needing to add a Jquery library in magento 1.9, to use on one of my phtml pages, to insert masks in my fields, like cpf, cnpj and etc ...



I have done a lot of research and I have noticed that the subject is very scarce, but very necessary, and I want to share this knowledge with you. There are a lot of details to watch out for, but with a lot of patience it works, I discovered the right and proper method to do this, and I also discovered the fast method if the first method does not work.










share|improve this question














bumped to the homepage by Community 40 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

    – Bartosz Herba
    Nov 14 '17 at 20:23











  • I am putting this example to anyone who uses version 1.9 and is encountering this problem.

    – Philip Ramkeerat
    Nov 14 '17 at 20:28
















0















I was needing to add a Jquery library in magento 1.9, to use on one of my phtml pages, to insert masks in my fields, like cpf, cnpj and etc ...



I have done a lot of research and I have noticed that the subject is very scarce, but very necessary, and I want to share this knowledge with you. There are a lot of details to watch out for, but with a lot of patience it works, I discovered the right and proper method to do this, and I also discovered the fast method if the first method does not work.










share|improve this question














bumped to the homepage by Community 40 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

    – Bartosz Herba
    Nov 14 '17 at 20:23











  • I am putting this example to anyone who uses version 1.9 and is encountering this problem.

    – Philip Ramkeerat
    Nov 14 '17 at 20:28














0












0








0








I was needing to add a Jquery library in magento 1.9, to use on one of my phtml pages, to insert masks in my fields, like cpf, cnpj and etc ...



I have done a lot of research and I have noticed that the subject is very scarce, but very necessary, and I want to share this knowledge with you. There are a lot of details to watch out for, but with a lot of patience it works, I discovered the right and proper method to do this, and I also discovered the fast method if the first method does not work.










share|improve this question














I was needing to add a Jquery library in magento 1.9, to use on one of my phtml pages, to insert masks in my fields, like cpf, cnpj and etc ...



I have done a lot of research and I have noticed that the subject is very scarce, but very necessary, and I want to share this knowledge with you. There are a lot of details to watch out for, but with a lot of patience it works, I discovered the right and proper method to do this, and I also discovered the fast method if the first method does not work.







magento-1.9 jquery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '17 at 20:20









Philip RamkeeratPhilip Ramkeerat

11




11





bumped to the homepage by Community 40 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 40 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

    – Bartosz Herba
    Nov 14 '17 at 20:23











  • I am putting this example to anyone who uses version 1.9 and is encountering this problem.

    – Philip Ramkeerat
    Nov 14 '17 at 20:28



















  • Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

    – Bartosz Herba
    Nov 14 '17 at 20:23











  • I am putting this example to anyone who uses version 1.9 and is encountering this problem.

    – Philip Ramkeerat
    Nov 14 '17 at 20:28

















Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

– Bartosz Herba
Nov 14 '17 at 20:23





Is Magento 1 still alive? :) and jquery problem still exist? :D There is an IT world where time flows much slower :D

– Bartosz Herba
Nov 14 '17 at 20:23













I am putting this example to anyone who uses version 1.9 and is encountering this problem.

– Philip Ramkeerat
Nov 14 '17 at 20:28





I am putting this example to anyone who uses version 1.9 and is encountering this problem.

– Philip Ramkeerat
Nov 14 '17 at 20:28










1 Answer
1






active

oldest

votes


















0














Well, I researched a lot and got two solutions, the first time, you added to the Jquery.js file that thinks of the magento/js/jquery/your-lib.js directory.



Done this, you will look at the page.xml file and add an addJs method that points to the location where you are inserting yourjquery.js file. (AddJS function, I will explain below)



Location ex: app/design/frontend/default/yourtheme/layout/page.xml.



Okay, coming out with no page.xml you'll see a method calling addJS which is basically a native function of Magento that aims to search the Magento JS directory, the file you want to add. Pay close attention here, you are already prepared to search the JS folder of the Magento, so basically, you do not like pasta.



So let's for example, add a JQuery.js library:



<action method = "addJs"> <script> jquery / name-of-your-lib-jquery.js </ script> </ action>


Note that I did not type js/jquery/... I just typed jquery/... being so following what I said above, which is already set and is not accurate Be referenced in your directory information.



Follow your steps and you do not have your Magento and your Jquery library, and then just use it for free. To find out what is working, reload the Magento, activate the browser console and search, not HTML a head tag and see the jquery libraries there, if it is showing up there, it is ok.



IF YOU DID NOT GET USING THE FIRST (MOST RECOMMENDED) METHOD ... Remember it may be easier, but I advise you to use the first way ...



SECOND WAY



It's basically the first thing you think about when it comes to doing something like that.



<script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/name-of-your-lib-jquery.js')?>"></script>


Final remarks: Syntax Jquery Magento 1.9



It's not your .phtml file, when you use a function without your Jquery, it uses your library you just added, and you get the error. Try using this syntax style:



jQuery ('input [id = "billing: example"]'). mask ("(00) 00000-0000");





share|improve this answer


























  • After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

    – Bartosz Herba
    Nov 14 '17 at 20:48













  • Thank you my friend, I just want to help someone, with a headache I had

    – Philip Ramkeerat
    Nov 28 '17 at 2:55











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f201522%2fhow-to-add-a-jquery-library-in-magento-1-9%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Well, I researched a lot and got two solutions, the first time, you added to the Jquery.js file that thinks of the magento/js/jquery/your-lib.js directory.



Done this, you will look at the page.xml file and add an addJs method that points to the location where you are inserting yourjquery.js file. (AddJS function, I will explain below)



Location ex: app/design/frontend/default/yourtheme/layout/page.xml.



Okay, coming out with no page.xml you'll see a method calling addJS which is basically a native function of Magento that aims to search the Magento JS directory, the file you want to add. Pay close attention here, you are already prepared to search the JS folder of the Magento, so basically, you do not like pasta.



So let's for example, add a JQuery.js library:



<action method = "addJs"> <script> jquery / name-of-your-lib-jquery.js </ script> </ action>


Note that I did not type js/jquery/... I just typed jquery/... being so following what I said above, which is already set and is not accurate Be referenced in your directory information.



Follow your steps and you do not have your Magento and your Jquery library, and then just use it for free. To find out what is working, reload the Magento, activate the browser console and search, not HTML a head tag and see the jquery libraries there, if it is showing up there, it is ok.



IF YOU DID NOT GET USING THE FIRST (MOST RECOMMENDED) METHOD ... Remember it may be easier, but I advise you to use the first way ...



SECOND WAY



It's basically the first thing you think about when it comes to doing something like that.



<script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/name-of-your-lib-jquery.js')?>"></script>


Final remarks: Syntax Jquery Magento 1.9



It's not your .phtml file, when you use a function without your Jquery, it uses your library you just added, and you get the error. Try using this syntax style:



jQuery ('input [id = "billing: example"]'). mask ("(00) 00000-0000");





share|improve this answer


























  • After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

    – Bartosz Herba
    Nov 14 '17 at 20:48













  • Thank you my friend, I just want to help someone, with a headache I had

    – Philip Ramkeerat
    Nov 28 '17 at 2:55
















0














Well, I researched a lot and got two solutions, the first time, you added to the Jquery.js file that thinks of the magento/js/jquery/your-lib.js directory.



Done this, you will look at the page.xml file and add an addJs method that points to the location where you are inserting yourjquery.js file. (AddJS function, I will explain below)



Location ex: app/design/frontend/default/yourtheme/layout/page.xml.



Okay, coming out with no page.xml you'll see a method calling addJS which is basically a native function of Magento that aims to search the Magento JS directory, the file you want to add. Pay close attention here, you are already prepared to search the JS folder of the Magento, so basically, you do not like pasta.



So let's for example, add a JQuery.js library:



<action method = "addJs"> <script> jquery / name-of-your-lib-jquery.js </ script> </ action>


Note that I did not type js/jquery/... I just typed jquery/... being so following what I said above, which is already set and is not accurate Be referenced in your directory information.



Follow your steps and you do not have your Magento and your Jquery library, and then just use it for free. To find out what is working, reload the Magento, activate the browser console and search, not HTML a head tag and see the jquery libraries there, if it is showing up there, it is ok.



IF YOU DID NOT GET USING THE FIRST (MOST RECOMMENDED) METHOD ... Remember it may be easier, but I advise you to use the first way ...



SECOND WAY



It's basically the first thing you think about when it comes to doing something like that.



<script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/name-of-your-lib-jquery.js')?>"></script>


Final remarks: Syntax Jquery Magento 1.9



It's not your .phtml file, when you use a function without your Jquery, it uses your library you just added, and you get the error. Try using this syntax style:



jQuery ('input [id = "billing: example"]'). mask ("(00) 00000-0000");





share|improve this answer


























  • After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

    – Bartosz Herba
    Nov 14 '17 at 20:48













  • Thank you my friend, I just want to help someone, with a headache I had

    – Philip Ramkeerat
    Nov 28 '17 at 2:55














0












0








0







Well, I researched a lot and got two solutions, the first time, you added to the Jquery.js file that thinks of the magento/js/jquery/your-lib.js directory.



Done this, you will look at the page.xml file and add an addJs method that points to the location where you are inserting yourjquery.js file. (AddJS function, I will explain below)



Location ex: app/design/frontend/default/yourtheme/layout/page.xml.



Okay, coming out with no page.xml you'll see a method calling addJS which is basically a native function of Magento that aims to search the Magento JS directory, the file you want to add. Pay close attention here, you are already prepared to search the JS folder of the Magento, so basically, you do not like pasta.



So let's for example, add a JQuery.js library:



<action method = "addJs"> <script> jquery / name-of-your-lib-jquery.js </ script> </ action>


Note that I did not type js/jquery/... I just typed jquery/... being so following what I said above, which is already set and is not accurate Be referenced in your directory information.



Follow your steps and you do not have your Magento and your Jquery library, and then just use it for free. To find out what is working, reload the Magento, activate the browser console and search, not HTML a head tag and see the jquery libraries there, if it is showing up there, it is ok.



IF YOU DID NOT GET USING THE FIRST (MOST RECOMMENDED) METHOD ... Remember it may be easier, but I advise you to use the first way ...



SECOND WAY



It's basically the first thing you think about when it comes to doing something like that.



<script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/name-of-your-lib-jquery.js')?>"></script>


Final remarks: Syntax Jquery Magento 1.9



It's not your .phtml file, when you use a function without your Jquery, it uses your library you just added, and you get the error. Try using this syntax style:



jQuery ('input [id = "billing: example"]'). mask ("(00) 00000-0000");





share|improve this answer















Well, I researched a lot and got two solutions, the first time, you added to the Jquery.js file that thinks of the magento/js/jquery/your-lib.js directory.



Done this, you will look at the page.xml file and add an addJs method that points to the location where you are inserting yourjquery.js file. (AddJS function, I will explain below)



Location ex: app/design/frontend/default/yourtheme/layout/page.xml.



Okay, coming out with no page.xml you'll see a method calling addJS which is basically a native function of Magento that aims to search the Magento JS directory, the file you want to add. Pay close attention here, you are already prepared to search the JS folder of the Magento, so basically, you do not like pasta.



So let's for example, add a JQuery.js library:



<action method = "addJs"> <script> jquery / name-of-your-lib-jquery.js </ script> </ action>


Note that I did not type js/jquery/... I just typed jquery/... being so following what I said above, which is already set and is not accurate Be referenced in your directory information.



Follow your steps and you do not have your Magento and your Jquery library, and then just use it for free. To find out what is working, reload the Magento, activate the browser console and search, not HTML a head tag and see the jquery libraries there, if it is showing up there, it is ok.



IF YOU DID NOT GET USING THE FIRST (MOST RECOMMENDED) METHOD ... Remember it may be easier, but I advise you to use the first way ...



SECOND WAY



It's basically the first thing you think about when it comes to doing something like that.



<script type="text/javascript" src="<?php echo $this->getJsUrl('jquery/name-of-your-lib-jquery.js')?>"></script>


Final remarks: Syntax Jquery Magento 1.9



It's not your .phtml file, when you use a function without your Jquery, it uses your library you just added, and you get the error. Try using this syntax style:



jQuery ('input [id = "billing: example"]'). mask ("(00) 00000-0000");






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '17 at 2:44









St3phan

1,9611136




1,9611136










answered Nov 14 '17 at 20:27









Philip RamkeeratPhilip Ramkeerat

11




11













  • After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

    – Bartosz Herba
    Nov 14 '17 at 20:48













  • Thank you my friend, I just want to help someone, with a headache I had

    – Philip Ramkeerat
    Nov 28 '17 at 2:55



















  • After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

    – Bartosz Herba
    Nov 14 '17 at 20:48













  • Thank you my friend, I just want to help someone, with a headache I had

    – Philip Ramkeerat
    Nov 28 '17 at 2:55

















After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

– Bartosz Herba
Nov 14 '17 at 20:48







After 10 years? Are you serious? :DD Magento ver 1.0.0 - Added March 31, 2008 I have a strong feeling that someone has already described it here, at least once :D

– Bartosz Herba
Nov 14 '17 at 20:48















Thank you my friend, I just want to help someone, with a headache I had

– Philip Ramkeerat
Nov 28 '17 at 2:55





Thank you my friend, I just want to help someone, with a headache I had

– Philip Ramkeerat
Nov 28 '17 at 2:55


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f201522%2fhow-to-add-a-jquery-library-in-magento-1-9%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown