• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Customizing news module backend with Jquery
PostPosted: Tue Feb 04, 2020 10:55 am 
Offline
Forum Members
Forum Members

Joined: Wed Aug 08, 2018 4:59 pm
Posts: 56
I'm having a slight problem with my news module back-end.

I've been customizing the "editarticle.tpl" so it will show/hide custom fields upon category selection.

It works fine when I create a new article in that specific category.(then the custom fields appears)

But if I want to edit the article, the custom fields are not showing.
To see the custom fields when I'm editing I have to select some other category (for example "General") and then select the previous category ( for example "CustomCategory"), then the custom fields are shown and I can edit them.

My Jquery is quite simple for this.
The custom fields are wrapped in <div id="cf_group">

And then there is this Jquery to show/hide the custom fields depending on witch category is selected.

\$1:
 $('select').change(function() {
  if ($(this).val() == 4) {
    $('#cf_group').show();
  } else {
    $('#cf_group').hide();
  }
});


As I said before this is working nicely when I create new article, but if I want to edit an article witch have the category with "option value = =4" (the one with all the custom fields). I first have to select another category and then the "option value = =4" category to see the custom fields.

What I want to be able to do is Just edit the articles without having to toggle between categories to edit the custom fields for the articles that are assign to the category with "option value = =4".

Can some one help me with this?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing news module backend with Jquery
PostPosted: Tue Feb 04, 2020 6:24 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Fri Apr 18, 2008 9:34 pm
Posts: 359
Location: Nimbin, Australia
i assume that on edit, the event is load, not change.
\$1:
  $('select').on('load change',function(e) {
    //your code
  } );


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Customizing news module backend with Jquery
PostPosted: Wed Feb 05, 2020 8:24 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8172
Location: Fernie British Columbia, Canada
if changing a category works fine to hide/show various fields... then when a page loads you should trigger the change event

\$1:
$(function(){
    $('selector').trigger('change');
});

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting