Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

where is this syntax error coming from?

Posted on 2013-05-15
9
Medium Priority
?
195 Views
Last Modified: 2013-05-15
I have a function like that someone here helped me with. This is the original function

$(document).live('pageinit', function () {
		
	$(window).bind('pageshow', function () {
		addBodyClass();
	});
	
	function getActiveSec(){
		return $('section.ui-page-active').attr('id');
	}
	function addBodyClass(){
		$('body').attr('class', getActiveSec());
	}
});

Open in new window


And I replaced it with "on" instead of "live". I get a syntax error at the last line but not sure how to fix it.  It looks like the curly brackets and paranthesis all match..so not sure

This is the new one:

$(document).on('pageinit',function(){
    addBodyClass();
	});
	
	function getActiveSec(){
		return $('section.ui-page-active').attr('id');
	}
	function addBodyClass(){
		$('body').attr('class', getActiveSec());
	}
 });

Open in new window

0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 1000 total points
ID: 39169248
remove line 11?
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 1000 total points
ID: 39169268
$(document).ready(function() {
	addBodyClass();
});
	
function getActiveSec(){
	return $('section.ui-page-active').attr('id');
}
function addBodyClass(){
	$('body').attr('class', getActiveSec());
}

Open in new window

0
 
LVL 7

Author Comment

by:Camillia
ID: 39169286
The orig code had line 11 and it was working fine. Let me try without it.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 58

Expert Comment

by:Gary
ID: 39169297
Ignore my comment it's exactly what leakim has pointed to. I just changed to document ready is the only difference
0
 
LVL 7

Author Comment

by:Camillia
ID: 39169301
Howcome line 11 was in the orig code (someone else has coded this) but i need to remove it in the new one?? Let me try it and see if it works without it.
0
 
LVL 7

Author Comment

by:Camillia
ID: 39169330
yeah, that was it. Not sure why the orig had it but the revised one doesnt. It works tho
0
 
LVL 7

Author Comment

by:Camillia
ID: 39169373
I think it's because i missed one line

$(window).bind('pageshow', function () {

so it should be

$(document).on('pageinit',function(){
 $(window).bind('pageshow', function () {
    addBodyClass();
      });
      
      function getActiveSec(){
            return $('section.ui-page-active').attr('id');
      }
      function addBodyClass(){
            $('body').attr('class', getActiveSec());
      }
});
0
 
LVL 58

Expert Comment

by:Gary
ID: 39169448
I didn't deserve any points
0
 
LVL 7

Author Comment

by:Camillia
ID: 39169504
yes, you did. You took the time to contribute.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question