In Rails how can I handle both Ajax request and normal HTML request in same action? -


my websites has tabbed format populate 2 out of 5 tabs in users home page. rest of tabs populated ajax request when user clicks on tab. suppose have action populate album tab using ajax upon tab click

def show_album     #code retrieve album     respond_to |format|         format.js {render :file => "path_offile.js.erb"}     end end 

inside js file use jquery selector show partial in empty tab-content space.

$('#albumtab').html("<%= j (render  :partial => 'profiles/show_my_album' )  %>"); 

the problem when want change url using history.pushstate "/show_album" when people reload page stay on album tab(sort of how works on facebook).

so when users reload page, come same action, cannot return js.erb file here there no existing page can add partial.

so , how should return action users can see album page. need create separate action normal http requests?

def show_album     #code retrieve album     respond_to |format|         format.js {render :file => "path_offile.js.erb"}         format.html{ <whatever stuff want happen here>}     end end 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -