?
Solved

where is this syntax error coming from?

Posted on 2013-05-15
9
Medium Priority
?
191 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
Create CentOS 7 Newton Packstack Running Keystone

A bug was filed against RDO for the installation of Keystone v3. This guide is designed to walk you through the configuration for using Keystone v3 with Packstack. You will accomplish this using various repos and the Answers file.

 
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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

762 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