Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

I am trying to add this custom javascript and css code in a page

<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    $('.subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

 $('.download').click(function() {
     $(this).parent().next('table').slideToggle('fast').css('display', 'block');
    });
  </script>

<style>
    .subject {
      color: #009fdb;
      display: block;
      font-size: 20px;
      margin: -5px 0px 5px;
      width: 100%;
    }
    .files {
      display: none;
    }
  </style>

Every time i got this error

<section class="handouts">

        <h1>Frequently asked subjects</h1>
        <p class="subject">ACC311 - Fundamentals of Auditing </p>
        <table class="files" align="right">
          <tr>
            <td>PDF</td>
            <td>PPT</td>
          </tr>
        </table>
        
</section>

You need to be a member of Ning Creators Social Network to add comments!

Join Ning Creators Social Network

Email me when people reply –

Replies

  • Hello,

    I got it to work on my Ning 2 site by adding the code to the Custom Code box, rather than the Head box on the custom page.

    Also you don't need to load the jQuery library because Ning does that for us already.  Ning's version of jQuery uses x$ rather than just $ so making that change made the download button appear for me.

    I used this code in the Custom Code box:

    <script type="text/javascript" charset="utf-8">
        x$('.subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

     x$('.download').click(function() {
         x$(this).parent().next('table').slideToggle('fast').css('display', 'block');
        });
      </script>

    <style>
        .subject {
          color: #009fdb;
          display: block;
          font-size: 20px;
          margin: -5px 0px 5px;
          width: 100%;
        }
        .files {
          display: none;
        }
      </style>

    Try it out here: http://jqueryhelp.ning.com/page/test-download-button

    Best wishes!

    TJ

    • Hi TJ!

      I checked your page and the code is working like a charm. I use the same code on my page but i got the same error i mentioned above. I don't know why i am getting this error. But i figured out something that, when i try to put HTML tags in javascript code, the custom box gives error. When i put the button tag in javascript code like this button> instead of this <button> the custom box accept the code. But the download button does not appear sometime. I am sure you will resolve my problem.

      Regards

      • Hello Innocent, try it like this..  It sounds like you have something in the head with the class or id the same as what you have in your script..  ".subject"  So we will add user generated to your code. Hopefully this helps.  You have a great day.

        <script type="text/javascript" charset="utf-8">
            x$('DIV.xg_user_generated .subject').append('<button class="download" style="float: right;">DOWNLOAD</button>');

         x$('DIV.xg_user_generated .download').click(function() {
             x$(this).parent().next('table').slideToggle('fast').css('display', 'block');
            });
          </script>

        <style>
           DIV.xg_user_generated .subject {
              color: #009fdb;
              display: block;
              font-size: 20px;
              margin: -5px 0px 5px;
              width: 100%;
            }
           DIV.xg_user_generated .files {
              display: none;
            }
          </style>

        • Hi George!

          Thanks for your great help. I have tried your modified javascript, but unfortunately it's still not working. I tried many things but the only working thing is that I need to break the starting tag of the button (<button>)to(button>), otherwise the code does not accept by the custom box. But the broken tag create problems and does not work every time. I think the javascript is not accepted if it got any html tag. I also try to put <input type="button"> instead of <button> but i got the same error. :(

          • I'm sorry it didn't work. :-(

            If you can send me a link to the page your adding this code to and I'll see if I can figure out the problem, like TJ said it should be working. We should be able to just target the individual page you are working on and add the code to your NC custom code box..

  • Okay, this should do the trick. The code goes in your NC custom code box. All the JavaScript and CSS have been compiled into one JavaScript code.

    If you change THE PAGE to a different page just change the page name in the first line of the code. What's in there right now is     "test-download-button"

    <script type="text/javascript" charset="utf-8">
    x$(document).ready(function(){0<=document.URL.indexOf("test-download-button")&&(x$(".subject").append('<button class="download" style="float: right;">DOWNLOAD</button>'),
    x$(".subject").css({color:"#009fdb",display:"block","font-size":"20px",margin:"-5px 0px 5px",width:"100%"}),
    x$(".files").css({display:"none"}),
    x$(".download").click(function(){x$(this).parent().next("table").slideToggle("fast").css("display","block")}))});
    </script>

  • It might be better doing it this way. Just add this code where you added it originally for each individual page.

    <script src="http://bit.ly/2dnMxi8" type="text/javascript" charset="utf-8"></script>
    <style>
        .subject {
          color: #009fdb;
          display: block;
          font-size: 20px;
          margin: -5px 0px 5px;
          width: 100%;
        }
        .files {
          display: none;
        }
      </style>

    • Hi George!

      Thanks for putting your head in it. I tried your new script, but unfortunately I got the same error. Then I use the external file you mentioned above the script is loaded, but I think its not working can you please take a look at it.

      http://vuhelp.pk/page/test-download-button

      Thanks again. :)

      • I've noticed the HTML portion of your code is in the head of the network it should not be there. See image below.



        And in your custom code box you have a misplaced ending script tag, which can cause errors. I don't see any of the codes in this discussion including mine installed on your network, except the HTML that is in the HEAD of your network.

        Here's what it looks like now in your custom code box
        <!--
        <script type="text/javascript" src="//s.skimresources.com/js/39610X1024039X3634.adunit.js">
        -->
        </script>

        Move the ending script tag so it looks like this

        <!--
        <script type="text/javascript" src="//s.skimresources.com/js/39610X1024039X3634.adunit.js"></script>
        -->

        When you fix those two errors try the codes again and if it doesn't work let me know and I'll have another look.

This reply was deleted.

Search the Creators Network

Latest Activity

Mike Collins replied to Kyryl_Ning_Support's discussion Paid Access demo version
"I'd like to be involved in looking at paid access demo please "
55 minutes ago
Harly replied to Ivy Williams's discussion Ning Roleplay Sites
2 hours ago
Kyryl_Ning_Support replied to Dr. Krishna Kumari Challa's discussion I am unable to find discussions on my network when I search. Any solutions?
"Hi there,
We are sorry for this. Previously we have been fixing the search on each network separate…"
4 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi there,
We are glad to know that you have been excited with this news. I have sent you the privat…"
5 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi Matt,
Yes, this post is regarding 3.0 platform only.
Regards,
Ning team."
5 hours ago
Lj Cange replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Exciting news..... I will be happy to assist!"
6 hours ago
Matt replied to Kyryl_Ning_Support's discussion Paid Access demo version
"So Ning 2 paid access will not be updated?"
7 hours ago
Dr. Krishna Kumari Challa replied to Dr. Krishna Kumari Challa's discussion I am unable to find discussions on my network when I search. Any solutions?
"Still the problem is not resolved!"
7 hours ago
Matt replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Is this only for Ning 3?"
8 hours ago
Hugh replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"I'd like to get some reassurance that support will be upgraded. I can't think of a time recently wh…"
11 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi Philip,
We are glad to hear that you are willing to help with the beta test, and it will be the…"
18 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi there,
Thanks for your endless support! We have sent you the private message regarding joining t…"
18 hours ago
Kyryl_Ning_Support replied to Aubrey Williams's discussion Paid Access 2017
"Hi there!
We do appreciate your feedback, yes we know that based on our history the people wouldn't…"
19 hours ago
Ning via Facebook

#unitewithNING You`re one click away from the place where all questions about #NING find their…

Kos replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Cannot express how happy I am to see Ning growing and expanding once again. It's been a long three…"
20 hours ago
Philip Voice replied to Aubrey Williams's discussion Paid Access 2017
"Thanks. I've applied to help evaluate and I'll make a decision about how I implement paid access in…"
22 hours ago
Philip Voice replied to Kyryl_Ning_Support's discussion Paid Access demo version
"I'm happy help"
22 hours ago
kevin carrasco is now a member of Ning Creators Social Network
yesterday
Kyryl_Ning_Support replied to Aubrey Williams's discussion Paid Access 2017
"Hi Philip,
It's not an issue if you wish to continue to use the other processor for the payments we…"
yesterday
Ning via Facebook

#inspirewithNING More talks, inspiration and success stories on #NING platform! Create your…

More…