We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Why does all javascript/jquery functioning of oxwall become disabled after I add jquery to the site? | Forum

Zachary
Zachary Sep 30 '14
I want to have a character count when adding a blog post.


My code is 

<script> $(document).ready(function() { var status = $("#counter") $("#post").keyup(function() { var cVal = jQuery(this).val() cVal = jQuery.trim(cVal) if(cVal.length == 0) return cVal = cVal.replace(/['\.\?"]/,"") var words = cVal.split(/\W/) var chars = cVal.length status.text("You've written "+words.length+" word(s) and "+chars+" characters.") }) }) </script>
it works but then all of a sudden my other functioning stop working.
I have the idea that there is a conflict maybe. Also I have to include the latest jquery script since it never worked without it.
I do not know why it is doing this?

Sean
Sean Oct 3 '14
Try this:

<script>
    $(document).ready(function(){
        var status = $("#counter");
        $("#post").keyup(function(){
            var cVal = jQuery(this).val();
            cVal = jQuery.trim(cVal);
            if(cVal.length == 0)
            {
                return;
            }
            cVal = cVal.replace(/['\.\?"]/,"");
            var words = cVal.split(/\W/);
            var chars = cVal.length;
            status.text("You've written "+words.length+" word(s) and "+chars+" characters.");
        })
    })
</script>

Zachary
Zachary Oct 3 '14
@sean Its not working. I have no idea why though. If I reference the latest jquery it works, but then all other javascript stops. Then I thought there maybe a conflict, when I inserted no conflict for the two to work simultaneously it still never worked.
Daisy Team
Daisy Nov 4 '14
Zachary, seems there is syntax error (see the screenshot). Please check if the code is correct.



Also, could you please specify how you added this script?